[Xapian-discuss] [issue] The difference between QueryParser::FLAG_AUTO_SYNONYMS and QueryParser::FLAG_AUTO_MULTIWORD_SYNONYMS

Richard Boulton richard at tartarus.org
Wed Jan 4 09:50:49 GMT 2012


On 4 January 2012 07:53, hightman <hightman at zuaa.zju.edu.cn> wrote:
> I don't know whether this is a BUG or for special purpose...
>
> According to the definition of "xapian/queryparser.h", FLAG_AUTO_MULTIWORD_SYNONYMS contains bit of
> FLAG_AUTO_SYNONYMS .

This is deliberate; the idea is that setting
FLAG_AUTO_MULTIWORD_SYNONYMS should imply FLAG_AUTO_SYNONYMS.

> Therefore, long as I set the parse flag with FLAG_AUTO_SYNONYMS, the query parser will automatically activate
> the function of FLAG_AUTO_MULTIWORD_SYNONYMS. See the below source code part from "queryparser.lemon"
>
> ...
> 1358     subqs.reserve(terms.size());
> 1359     if (state->flags & QueryParser::FLAG_AUTO_MULTIWORD_SYNONYMS) {
> 1360         // Check for multi-word synonyms.
> 1361         Database db = state->get_database();

This is a bug, I think.  As you observe, this "if" clause evaluates to
true if flags is set to FLAG_AUTO_SYNONYMS.  I think this could be
fixed by changing line 1359 (above) to

if (state->flags & 1024) {

but this isn't very clean.  We should probably be defining an
appropriate constant in queryparser.h and using that here.

-- 
Richard



More information about the Xapian-discuss mailing list