[Xapian-discuss] Searching in all "fields" by default

Daniel Ménard Daniel.Menard at ehesp.fr
Mon Nov 24 09:29:01 GMT 2008


Henry a écrit :
> Conclusion:  index every term with and _without_ prefixes...  Lots of  
> extra indexing time and space consumption, but I guess that's the way  
> it is.
>   
You can also use QueryParser::add_prefix() to map multiple prefixes to 
the "empty string" field name:
http://www.xapian.org/docs/apidoc/html/classXapian_1_1QueryParser.html#dfd545b4ac739adc2e4171169a500f33

e.g.
qp.add_prefix("", "XTITLE");
qp.add_prefix("", "XSITE");
qp.add_prefix("", "XYZ");
q=qp.parse_query("bob") ;
will give something like "XTITLEbob OR XSITEbob OR XYZbob".

It requires xapian >= 1.04, and you must not specify the default_prefix 
parameter to parse_query.

If you really have a lot of fields, it will lead to somewhat complex 
queries, but it works really fine for us.

-- 

Daniel Ménard




More information about the Xapian-discuss mailing list