[Xapian-discuss] QueryParser is strange with boolean filter
Sungsoo Kim
xingshou at gmail.com
Thu Apr 13 03:37:44 BST 2006
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
More information about the Xapian-discuss
mailing list