You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Chris Hostetter <ho...@fucit.org> on 2009/07/01 00:45:20 UTC

Re: DisMaxRequestHandler usage

: Date: Tue, 16 Jun 2009 21:26:37 +0000
: From: siping liu
: Subject: DisMaxRequestHandler usage

: q=(field1:hello OR field2:hello) AND (field3:world)
: 
: Can I use dismax handler for this (applying the same search term on 
: field1 and field2, but keep field3 with something separate)? If it can 
: be done, what's the advantage of doing it this way over using the 
: standard query?

The point of dismax is to make your syntax simpler, in exchange for more 
configuration.  you can't produce that exact query using dismax, but lets 
change your orriginal query slightly first...

   fq=field3:world  &  q=(field1:hello OR field2:hello)

...the set of documents returned will be the same as your query, but the 
scores will only be based on the word "hello" against field1 and field2 -- 
the "field3:world" clause will only be used to filter (restrict) 
which documents are allowed.

Assuming that change regarding field3:world is okay with you, then the 
main reason you might want to use dismax for a query like this is that the 
same query can be expressed like this...

   fq=field3:world   &   qf=field1 field2  &  q=hello

...now you've moved the "hello" part into it's own param that can come 
from your users, while the "field1 field2" part can come from somewhere in 
your code, and users never have to type it, or even know it's there.  you 
can even default it in the solrconfig.xml, and change it all you want 
without them ever knowing about it.




-Hoss