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 Gnanakumar <gn...@zoniac.com> on 2011/05/19 12:13:33 UTC

How do I write/build query using "qf" parameter of dismax handler for my use case?

Hi,

How do I write/build a Solr query using dismax handler for my application
specific use case explained below:

Snippet of fields definition from schema.xml:

<field name="documentid" type="string" indexed="true" stored="true"
required="true" />
<field name="companyid" type="long" indexed="true" stored="true"
required="true" />
<field name="textfield1" type="text" indexed="true" stored="false"
required="true" />
<field name="textfield2" type="text" indexed="true" stored="false"
required="true" />
<field name="textfield3" type="text" indexed="true" stored="false"
required="true" />

<uniqueKey>documentid</uniqueKey>
<defaultSearchField>textfield1</defaultSearchField>

Now, I want to search for documents containing "solr" and "struts" in all 3
text fields (textfield1, textfield2, textfield3) but within the companyid =
100.

As you can see from above statement, companyid=100 is common here but search
keywords should be searched only in 3 text fields (textfield1, textfield2,
textfield3).

I also understand that this can be written as shown below by qualifying all
the 3 text fields explicitly:
http://localhost/solr/select?q=companyid:100&textfield1:solr AND
struts&textfield2:solr AND struts&textfield3:solr AND struts

But how do I write/build a query using "qf" parameter of dismax query
handler, so that I don't need to specify all the 3 fields explicitly.

Wiki says: "For each "word" in the query string, dismax builds a
DisjunctionMaxQuery object for that word across all of the fields in the qf
param"

NOTE: I'm using "edismax" as my default query type in my Search Handler.

Regards,
Gnanam


RE: How do I write/build query using "qf" parameter of dismax handler for my use case?

Posted by Gnanakumar <gn...@zoniac.com>.
> edismax supports full query format of lucene parser.But you can search
using
> filter queries eg.

> qf=textfield1, textfield2, textfield3&fq=&textfield1:solr AND
> struts&fq=textfield2:solr AND struts&fq=textfield3:solr AND struts
> &fq=companyid:100
Is it not possible to build query without filter queries "fq"?

For example, something like this (I believe this is syntactically not
correct, but something equivalent to this):
q=companyid:100 AND solr AND struts&qf= textfield1,textfield2,textfield3

Basically, I'm just trying/finding to simplify the query syntax.


Re: How do I write/build query using "qf" parameter of dismax handler for my use case?

Posted by Grijesh <pi...@gmail.com>.
edismax supports full query format of lucene parser.But you can search using
filter queries eg.

qf=textfield1, textfield2, textfield3&fq=&textfield1:solr AND
struts&fq=textfield2:solr AND struts&fq=textfield3:solr AND struts
&fq=companyid:100


-----
Thanx: 
Grijesh 
www.gettinhahead.co.in 
--
View this message in context: http://lucene.472066.n3.nabble.com/How-do-I-write-build-query-using-qf-parameter-of-dismax-handler-for-my-use-case-tp2960766p2960911.html
Sent from the Solr - User mailing list archive at Nabble.com.