[Xapian-discuss] wildcards and prefix searches

Donncha Redmond dredmond at e-xact.com
Fri Aug 22 06:36:14 BST 2008


On 22/08/2008, at 11:53 AM, Olly Betts wrote:
> Can you supply a self-contained example which reproduces this?

Olly,

I've confirmed that it's an acts_as_xapian issue. acts_as_xapian uses  
query_parser.add_boolean_prefix and not query_parser.add_prefix which  
seems to cause the problem.

Here's some rudimentary Ruby code based on the test you mentioned,  
showing the relevant query descriptions. The Q2 description is what  
acts_as_xapian is currently producing.

I'll chase it up with Francis.

Thanks for your pointer to the relevant C++ test,

donncha

====
require 'xapian'

database = Xapian::WritableDatabase.new("test.db",  
Xapian::DB_CREATE_OR_OVERWRITE)
doc = Xapian::Document.new
doc.add_term("Aheinlein")
doc.add_term("Ahelter")
doc.add_term("Ahuxley")
doc.add_term("hello")
database.add_document(doc)

qp = Xapian::QueryParser.new
qp.database = database
qp.add_prefix("author", "A")

q = qp.parse_query("author:h*", Xapian::QueryParser::FLAG_WILDCARD)
puts "add_prefix: " + q.description

qp = Xapian::QueryParser.new
qp.database = database
qp.add_boolean_prefix("author", "A")
q = qp.parse_query("author:h*", Xapian::QueryParser::FLAG_WILDCARD)
puts "add_boolean_prefix: " + q.description

Produces:
add_prefix: Xapian::Query((Aheinlein:(pos=1) OR Ahelter:(pos=1) OR  
Ahuxley:(pos=1)))
add_boolean_prefix: Xapian::Query(0 * Ah*)




More information about the Xapian-discuss mailing list