Note that there are some explanatory texts on larger screens.

plurals
  1. POXapian filtering with whitespace
    primarykey
    data
    text
    <p>How to filter search result with query with has white space.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;xapian.h&gt; struct document{ std::string title; std::string content; std::string url; }; void indexData(document d) { try { Xapian::WritableDatabase db("/Users/ramesh/Desktop/xapian", Xapian::DB_CREATE_OR_OPEN); Xapian::TermGenerator indexer; Xapian::Stem stemmer("english"); indexer.set_stemmer(stemmer); Xapian::Document doc; doc.set_data(d.title); indexer.set_document(doc); indexer.index_text(d.title,1,"title"); indexer.index_text(d.content,1,"content"); indexer.index_text(d.url,1,"url"); doc.add_boolean_term("title"+d.title); db.replace_document(d.url,doc); db.commit(); } catch (const Xapian::Error &amp;e) { std::cout &lt;&lt; e.get_description() &lt;&lt; std::endl; exit(1); } } void searchData(std::string query_string){ try{ Xapian::Database db("/Users/ramesh/Desktop/xapian"); Xapian::Enquire enquire(db); Xapian::QueryParser qp; Xapian::Stem stemmer("english"); qp.set_default_op(Xapian::Query::OP_FILTER); qp.set_stemmer(stemmer); qp.add_prefix("","title"); qp.add_prefix("","content"); qp.add_boolean_prefix("title","title"); qp.set_database(db); qp.set_stemming_strategy(Xapian::QueryParser::STEM_SOME); Xapian::Query query = qp.parse_query(query_string); std::cout &lt;&lt; "Parsed query is: " &lt;&lt; query.get_description() &lt;&lt; std::endl; enquire.set_query(query); Xapian::MSet matches = enquire.get_mset(0, 10); std::cout &lt;&lt; matches.get_matches_estimated() &lt;&lt; " results found.\n"; std::cout &lt;&lt; "Matches 1-" &lt;&lt; matches.size() &lt;&lt; ":\n" &lt;&lt; std::endl; for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i) { std::cout &lt;&lt; i.get_rank() + 1 &lt;&lt; ": " &lt;&lt; i.get_weight() &lt;&lt; " docid=" &lt;&lt; *i &lt;&lt; " [" &lt;&lt; i.get_document().get_data() &lt;&lt; "]\n\n"; } } catch (const Xapian::Error &amp;e) { std::cout &lt;&lt; e.get_description() &lt;&lt; std::endl; exit(1); } } int main() { document d1,d2; d1.title = "Xapain is good"; d1.content = "Xapian is an open source search engine library, which allows developers to add advanced indexing and search facilities to their own applications."; d1.url = "http://www.xapian.org"; d2.title = "Xapain is awesome"; d2.content = "good Xapian is an open source search engine library, which allows developers to add advanced indexing and search facilities to their own applications."; d2.url = "http://www.xapian.org/test"; indexData(d1); indexData(d2); searchData("xapian title:good"); searchData("xapian title:Xapian is good"); return 0; } </code></pre> <p>First query "xapian title:good" works well.</p> <p>But "xapian title:Xapian is good" fails.</p> <p>Can any one please explain what is the issue</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload