[Xapian-discuss] Queryparser and Boolean

Olly Betts olly at survex.com
Mon Apr 7 15:31:04 BST 2008


On Mon, Apr 07, 2008 at 02:52:37PM +0100, Colin Bell wrote:
> qp.set_default_op(Xapian::Query::OP_OR);
> qp.set_stemmer(Xapian::Stem("english"));
> qp.set_stemming_strategy(Xapian::QueryParser::STEM_ALL);
> qp.set_stopper(new MyStopper());
> qp.set_database(db);
> Xapian::Query query;
> query = qp.parse_query(text,  
> Xapian::QueryParser::FLAG_SPELLING_CORRECTION| 
> Xapian::QueryParser::FLAG_BOOLEAN|Xapian::QueryParser::FLAG_PHRASE);

Incidentally, you can refer to the flags via an object of the type, so
qp.FLAG_BOOLEAN works and is shorter!

> So when I do a search such as "(pension funds) AND (barclays bank)" or  
> "(pension funds) NOT (barclays bank)" I get the same results.
> 
> I'm obviously being daft and not doing something right, but I can't  
> see what it is.

It can be helpful to see what the query you get is:

    cout << query.get_description() << endl;

Trying out similar queries, it looks like there's an odd bug here and
the first term in the first bracket is being eaten by something (but
I don't get the same query, although perhaps the two queries without
`a' give you the same results).

Anyway, I'll investigate.

Cheers,
    Olly



More information about the Xapian-discuss mailing list