goran kent
2010-Sep-25 12:31 UTC
[Xapian-discuss] Newbie question: searching certain fields only
Hallo, I'm new to xapian and have only started checking it out, so please forgive my silly questions. I'm trying to get my head around the following: Given the following fields (values with prefixes): Name: .... Surname: .... Address: .... ... How can I (by default) search in Name and Surname only? ie, I want to ignore the Address field during search, unless I explicitly search it (eg, by using "+address:..." in my query). I don't want to add "-address:..." to the query (even silently in the background) since this might inadvertently exclude desired results. Sorry if my question is not very clear. Any suggestions welcome. Thanks
Matt Goodall
2010-Sep-25 14:38 UTC
[Xapian-discuss] Newbie question: searching certain fields only
On 25 September 2010 13:31, goran kent <gorankent at gmail.com> wrote:> Given the following fields (values with prefixes): > > Name: ?.... > Surname: ?.... > Address: .... > ... > > How can I (by default) search in Name and Surname only? ?ie, I want to > ignore the Address field during search, unless I explicitly search it (eg, > by using "+address:..." in my query). > > I don't want to add "-address:..." to the query (even silently in the > background) since this might inadvertently exclude desired results.Hi, The best way is probably to add terms both with and without the field prefix for the 'Name' and 'Surname' fields, but only with the prefix for the 'Address' field. You then end up with an index containing something like the following keys: matt XNAMEmatt goodall XSURNAMEgoodall XADDRESS123 XADDRESSwiggly XADDRESSroad (not my real address ;-)) A search for "matt" will match any terms from the 'Name' or 'Surname' fields. An "address:...", "name:...", etc search will match only the prefixed terms as before. Hope that helps. - Matt