hightman
2012-Jan-04 07:53 UTC
[Xapian-discuss] [issue] The difference between QueryParser::FLAG_AUTO_SYNONYMS and QueryParser::FLAG_AUTO_MULTIWORD_SYNONYMS
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 . 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(); ...
Richard Boulton
2012-Jan-04 09:50 UTC
[Xapian-discuss] [issue] The difference between QueryParser::FLAG_AUTO_SYNONYMS and QueryParser::FLAG_AUTO_MULTIWORD_SYNONYMS
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
Olly Betts
2012-Jan-16 23:04 UTC
[Xapian-discuss] [issue] The difference between QueryParser::FLAG_AUTO_SYNONYMS and QueryParser::FLAG_AUTO_MULTIWORD_SYNONYMS
On Wed, Jan 04, 2012 at 03:53:15PM +0800, hightman wrote:> 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.Thanks for reporting this - I've committed a fix to trunk (r16317) and will backport it for 1.2.9. Cheers, Olly