[Xapian-discuss] Combined search in multiple fields help

Do. do1 at yandex.ru
Sun Dec 13 03:52:59 GMT 2009


Hello,

I want to let user specify by drop down list to what fields his query will be searched. For example "Full-text" or "Title+Author", then user enters search query as usual (without using prefixes). But how to modify query so it cover two fields in a right way?

For a starter how I think about modifying query to limit it just to single globally selected field:
1. after user enters free-text query I parse it as usual via parse_query(),
2. then I iterate through resulting Xapian::Query by get_terms and apend A or S prefix to evey term (after Z if Z is present, and not appending where other prefix is already applied (for example H)).
(Btw, is this optimal strategy?)

What I think about multiple fields and where it fail:
There is two situation depending on default_op().
'or') I just duplicate parsed query as whole and add different prefix to each of them, then combine these big queries with 'or'.
'and') hard part begin, probably I should duplicate each term, add one prefix to original and other to clone and combine it with OR with existing term. Right? Will this be possible? Any suggestions?

Don.





More information about the Xapian-discuss mailing list