Sungsoo Kim
2006-Apr-13 03:39 UTC
[Xapian-discuss] QueryParser is strange with boolean filter
I have encountered something strange with QueryParser.
This is not critical because I have found how to avoid this
problem.
In the following results, D, E cases are something unexpected.
I could avoid this by changing the input string into the format
as case F without plus sign in boolean filter terms.
1. version : xapian 0.9.4 version with UTF-8 patch
2. parse query source code
qp = xapian.QueryParser()
qp.set_database(database)
qp.set_default_op(xapian.Query.OP_AND)
qp.set_stemming_strategy(xapian.QueryParser.STEM_NONE)
qp.add_boolean_prefix("XTYPE", "XTYPE:")
query = qp.parse_query(input,
xapian.QueryParser.FLAG_BOOLEAN |
xapian.QueryParser.FLAG_BOOLEAN_ANY_CASE |
xapian.QueryParser.FLAG_PHRASE |
xapian.QueryParser.FLAG_LOVEHATE |
xapian.QueryParser.FLAG_WILDCARD)
print "Performing query '%s'" % query.get_description()
3. test result
Case A: OK
$ python search.py -v cup XTYPE:H XTYPE:V
Performing query 'Xapian::Query((cup:(pos=1) FILTER (XTYPE:H AND
XTYPE:V)))'
Case B: OK
$ python search.py -v cup +XTYPE:H +XTYPE:V
Performing query 'Xapian::Query((cup:(pos=1) FILTER (XTYPE:H AND
XTYPE:V)))'
Case C: OK
$ python search.py -v cup -XTYPE:H -XTYPE:V
Performing query 'Xapian::Query((cup:(pos=1) AND_NOT (XTYPE:H OR
XTYPE:V)))'
Case D: ?
$ python search.py -v cup -XTYPE:H +XTYPE:V
Performing query 'Xapian::Query((cup:(pos=1) FILTER (XTYPE:H AND
XTYPE:V)))'
Case E: ?
$ python search.py -v cup +XTYPE:H -XTYPE:V
Performing query 'Xapian::Query((cup:(pos=1) FILTER (XTYPE:H AND
XTYPE:V)))'
Case F: OK
$ python search.py -v cup XTYPE:H -XTYPE:V
Performing query 'Xapian::Query(((cup:(pos=1) AND_NOT XTYPE:V) FILTER
XTYPE:H))'
Sungsoo Kim
Olly Betts
2006-Apr-13 14:46 UTC
[Xapian-discuss] QueryParser is strange with boolean filter
On Thu, Apr 13, 2006 at 11:37:44AM +0900, Sungsoo Kim wrote:> Case D: ? > $ python search.py -v cup -XTYPE:H +XTYPE:V > Performing query 'Xapian::Query((cup:(pos=1) FILTER (XTYPE:H AND XTYPE:V)))' > > Case E: ? > $ python search.py -v cup +XTYPE:H -XTYPE:V > Performing query 'Xapian::Query((cup:(pos=1) FILTER (XTYPE:H AND XTYPE:V)))'The problem is that there's no case to handle "+XTYPE:H" so the QueryParser goes into its fallback mode (assuming this is pasted text) and strips the "+" and "-" signs. Could you confirm that this patch fixes it: http://www.oligarchy.co.uk/xapian/patches/queryparser-love-filter.patch You'll need to apply it in the queryparser subdirectory. Cheers, Olly