Hi all,

a customer recently asked me an interesting question.
They are a travel website, and they would like to support queries like "Easter on a tropical island beach". They would like this to match anything that would be matched by "on a tropical island beach", but also match e.g. Easter island (with an adjustable boost). Bonus points for also matching all terms as a phrase. Of course we have covered the basics as far as stopwords, but there's obviously more to be done here. We also use the mm parameter to make fewer terms required as the query becomes more complex, and that's actually the key to the question: our mm parameter would need to apply only to the "on a tropical island beach" portion, with Easter being totally optional.

My first attempt was: _query_:"{!dismax}:easter" OR _query_:"{!dismax}on a tropical beach" This has the advantage that we could get as sophisticated as we want in deciding where can "Easter" match (for instance in the name of a destination, but not on tags); also, it would let us control the mm on the other part of the query. I still need to add another term to match the full sentence (with a high boost, presumably), but I don't think that would be a problem.

However, before I start implementing this I was wondering, am I missing something? is there a way to tell DisMax to make one term completely optional, regardless of what mm requires?
And then of course there's the option of subclassing a query parser...

What do you think?

Andrea

Reply via email to