search for: set_query

Displaying 20 results from an estimated 27 matches for "set_query".

Did you mean: get_query
2005 Feb 24
2
mutable Query objects
There's a bit of an API glitch with Query objects at present. This code shows it off: Xapian::Database("/path/to/db"); Xapian::Enquire enquire(db); // make a simple query Xapian::Query myquery(Xapian::Query::OP_NEAR, phrase, phrase + 2); enquire.set_query(myquery); // Now change the query - this shouldn't affect the query enquire // will run, but it does. myquery.set_window(10); The essential issue here is that queries are mutable, so Enquire::set_query() needs to clone the Query object to stop it being changed behind the scenes. I can see...
2013 Oct 23
2
performance on document.get_data()
...message(30 words) Do you have any idea to improve the search performance , especially doc.get_data? my code snippet database = xapian.Database("%s/athena" % DATA_PATH) enquire = xapian.Enquire(database) enquire.set_weighting_scheme(xapian.BM25Weight()) query = parse(keywords) enquire.set_query(query) matches = enquire.get_mset(start, 200) matches.fetch() result = [json.loads(match.document.get_data()) for match in matches]
2010 Oct 21
2
In-memory databases vs PHP Bindings
...39;t work out how to create an in-memory database via the PHP bindings. Here's what I've got so far, using a disk-based index with an automatic backend (third line from the end is the critical one): // Find the document in the posts index $xenq = new XapianEnquire($xdb_posts); $xenq->set_query(new XapianQuery("UIDpost".$postid)); $xdoc = $xenq->get_mset(0, 1)->begin()->get_document(); // Create a database that just contains the one document // TODO:AB:20101020: Work out how to build an in-memory Xapian database via PHP bindings $xdb_doc = new XapianWritableDatabase(P...
2006 Dec 06
1
Bug and patch for +terms with wildcards
...queryparser.set_stemming_strategy(Xapian::QueryParser::STEM_ALL); + Xapian::Database db = get_database("apitest_simpledata"); + queryparser.set_database(db); + Xapian::Enquire enquire(db); + + Xapian::Query qobj = queryparser.parse_query("th*", flags); + enquire.set_query(qobj); + Xapian::MSet mymset = enquire.get_mset(0, 10); + // Check that 6 documents were returned. + TEST_MSET_SIZE(mymset, 6); + + qobj = queryparser.parse_query("notindb* this", flags); + enquire.set_query(qobj); + mymset = enquire.get_mset(0, 10); + // Check that 6...
2008 Sep 27
3
Query::MatchAll
Why there still been rank when using Query::MatchAll() ?
2007 Mar 29
1
"Bad serialised query" error
...#39;t managed to get a C++ reproduction in the test suite, but I have got a demo that fails using Python: import xapian db = xapian.remote_open('localhost', 8100) qp = xapian.QueryParser() qp.set_database(db) query = qp.parse_query('test') enq = xapian.Enquire(db) enq.set_query(query) enq.get_mset(0, 10) This script fails with: xapian.InvalidArgumentError: REMOTE:Bad serialised query I've tracked it down to api/omqueryinternal.cc, in QUnserial::readquery(), and is the 2nd occurance of that error message in that function (ie, inside the "case '['&qu...
2007 Feb 02
1
Working demo of search engine using boolean query.
...--------------------------------------------------------------------# my $query1 = Search::Xapian::Query->new( OP_OR, @primary_terms ); my $query2 = Search::Xapian::Query->new( OP_OR, @secondary_terms ); my $boolean_query = Search::Xapian::Query->new( OP_AND, $query1, $query2 ); $enq->set_query( $boolean_query ); #------------------------------------------------------------------------------# printf "Parsing query '%s'\n", $enq->get_query()->get_description(); my $total = $enq->matches(1, 100000000); print "Total: $total results found.\n-----------------...
2009 Mar 02
0
Xapian, PHP bindings and
...qp->parse_query( $query_string ); //, XapianQueryParser::FLAG_SPELLING_CORRECTION); print 'Parsed query is: '. $query->get_description() .'<br />'."\n"; // Find the top 10 results for the query. $enquire->set_query($query); $matches = $enquire->get_mset(0, 100); //correction spelling echo '<hr />'; $i = $database->spellings_begin(); while( ! $i->equals( $database->spellings_end())) {...
2009 Aug 17
1
Xapian DatabaseError
...gt;set_stemmer($stemmer); $qp->set_database($database); $qp->set_stemming_strategy(XapianQueryParser::STEM_SOME); $query = $qp->parse_query($query); echo "<br>Parsed query is: {$query->get_description()}\n"; $enquire->set_query($query); $matches = $enquire->get_mset(0, 10); ...... ?> 3) To test the code as php script --> As php script it work as php page not work <?php require_once 'search_function.inc'; simpleSearch("hello","xapian_db"); ?>
2011 Aug 10
0
xapian enquire.set_docid_order(Xapian::Enquire::DESCENDING so slow!
...xapian.Database(db_path) terms = ' '.join(terms) qp = xapian.QueryParser() qp.set_database(database) qp.set_default_op(0) #0:OP_AND; 1:OP_OR default query = qp.parse_query(terms) enquire = xapian.Enquire(database) enquire.set_weighting_scheme(xapian.BoolWeight()) enquire.set_query(query) enquire.set_docid_order(enquire.DESCENDING) matches = enquire.get_mset(0,10) print "%i results found . " % matches.get_matches_estimated() print "Results 1-%i:" % matches.size() for m in matches: print "rand= %-4d docid=%-8i" % (m.rank+1,m.doci...
2012 Nov 03
1
get the title from the document
...x document ??????? indexer.set_document(document) ??????? indexer.index_text(content)?????????????????? ??????? ??????? #Store indexed content in database ??????? database.add_document(document) ///////////// code? for searching? ??? query = queryParser.parse_query(queryString)??? ??? enquire.set_query(query) ??? matches = enquire.get_mset(offset, limit) ??? for match in matches:????? ??????? print 'rank=%s, documentID=%s' % (match.rank, match.docid) ??????? print match.document.get_data() //////////// end of the code Everything works weell. Now my question is how to get the title for...
2013 Jun 19
2
Compact databases and removing stale records at the same time
...void *rock) { int r = 0; int count = 0; try { /* set up a cursor to read from all the source databases */ Xapian::Database *srcdb = new Xapian::Database(); while (*sources) { srcdb->add_database(Xapian::Database(*sources++)); } Xapian::Enquire enquire(*srcdb); enquire.set_query(Xapian::Query::MatchAll); Xapian::MSet matches = enquire.get_mset(0, srcdb->get_doccount()); /* create a destination database */ Xapian::WritableDatabase *destdb = new Xapian::WritableDatabase(dest, Xapian::DB_CREATE_OR_OPEN); destdb->begin_transaction(); /* copy all matching documents...
2018 Jun 21
0
Welcome to the "Xapian-discuss" mailing list
...) tg.index_text("I am walking, always walking.") db.add_document(doc) Then you can run NEAR queries: import xapian db = xapian.Database("testdb") qp = xapian.QueryParser() qp.set_database(db) def query(query): enq = xapian.Enquire(db) q = qp.parse_query(query) enq.set_query(q) for match in enq.get_mset(0, 10): print(match.docid) query("I NEAR/1 walking") # prints nothing query("I NEAR/2 walking") # prints 1 There's no document in the database where "I" is adjacent to "walking". However there is one where it'...
2007 Feb 09
1
PHP Binding and dbi2omega questions
...tabase using the php xapian bindings like so: <?php include "xapian.php"; // Open our xapian database $db = Xapian::auto_open('/usr/local/lib/omega/data/default'); $enq = new XapianEnquire($db); // Query for "php" or "mysql" $enq->set_query(new XapianQuery(XapianQuery::OP_OR, "php", "mysql")); // lets grab the matches! $mset = $enq->get_mset(0, 10); // output how many estimated echo 'Matches: '.$mset->get_matches_estimated().'<br/>'; // Output the terms that matched...
2014 Mar 26
3
about sort_by_value
Hello, I have found that the use of sort_by_value very slow. 16800 result, return to the previous 10, sorting takes about 25ms. And if you do not sort, returns 10, need only about 0.3ms. How to make the sort faster? -------------- next part -------------- An HTML attachment was scrubbed... URL:
2015 Jan 16
2
Question on "single writer, multiple reader"
...string line; getline(cin, line); Xapian::Query query(line); cout << "Performing query `" << query.get_description() << "'" << endl; // Give the query object to the enquire session enquire.set_query(query); // Get the top 10 results of the query Xapian::MSet matches = enquire.get_mset(0, 10); // Display the results cout << matches.size() << " results found" << endl; for (Xapian::MSetIterator i = matches.b...
2013 Jul 03
2
Potential memory leak when assigning MSetItem values
...x.DB_CREATE) for i in xrange(1, num_docs): doc = x.Document() doc.set_data(json.dumps({ 'id': i, 'enabled': True })) doc.add_term('XTYPA') db.add_document(doc) return db def run_query(db, num_docs=100000): e = x.Enquire(db) e.set_query(x.Query('XTYPA')) m = e.get_mset(0, num_docs, True, None) # Store the MSetItem's data, which causes a memory leak data = [] for i in m: data.append({ 'data': i.document.get_data(), 'id': i.docid, }) # Make sure I'm not crazy del num_...
2013 Sep 22
2
How to filter search result with query with has white space.
...quot;title"); qp.set_database(db); qp.set_stemming_strategy(Xapian::QueryParser::STEM_SOME); Xapian::Query query = qp.parse_query(query_string); std::cout << "Parsed query is: " << query.get_description() << std::endl; enquire.set_query(query); Xapian::MSet matches = enquire.get_mset(0, 10); std::cout << matches.get_matches_estimated() << " results found.\n"; std::cout << "Matches 1-" << matches.size() << ":\n" << std::endl; for (Xapi...
2013 Sep 22
2
How to filter search result with query with has white space.
...quot;title"); qp.set_database(db); qp.set_stemming_strategy(Xapian::QueryParser::STEM_SOME); Xapian::Query query = qp.parse_query(query_string); std::cout << "Parsed query is: " << query.get_description() << std::endl; enquire.set_query(query); Xapian::MSet matches = enquire.get_mset(0, 10); std::cout << matches.get_matches_estimated() << " results found.\n"; std::cout << "Matches 1-" << matches.size() << ":\n" << std::endl; for (Xapi...
2015 Jul 26
1
Get term from document by position
...quot;\n###################################################\n"; Xapian::Query query = qp.parse_query(query_string); std::cout << "\nParsed query is: " << query.get_description() << "\n\n\n"; // Find the top 10 results for the query. enquire.set_query(query); Xapian::MSet matches = enquire.get_mset(0, 10); // Display the results. std::cout << matches.get_matches_estimated() << " results found.\n"; Xapian::Snipper snippet_generator; snippet_generator.set_stemmer(stemmer); snippet_gener...