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 "Whelan, Andy" <aw...@srcinc.com> on 2016/07/15 19:32:15 UTC

using lucene parser syntax with eDisMax

Hello,

I am using the eDisMax parser and have the following question.
With the eDisMax parser we can pass a query, q="brown and mazda",  and configure a bunch of fields in a solrconfig.xml SearchHandler to query on as "qf". Let's say I have a SOLR schema.xml with the following fields:
<field name="color" type="text_general" indexed="true" stored="true"/>
<field name="brand" type="text_general" indexed="true" stored="true"/>

and the following request handler in solrconfig.xml:
<requestHandler name="/select" class="solr.SearchHandler" default="true">
        <lst name="defaults">
            <str name="defType">edismax</str>
            <str name="qf">color brand</str>
     </lst>
</ requestHandler>

This makes boosting very easy.  I can execute a query "q=brown^2.0 and mazda^3.0") against the query handler "/select" above without specifying fields in the query string.  I can do this without having to copy color and brand to a specific catch all field as I would with the "lucene" parser (which would be configured as the default field "df").
The documentation at https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser says that eDisMax "supports the full Lucene query parser syntax".
Does this mean that a query string "color:brown^2 and mazda" is legal with eDisMax too?  Notice that I am specifying the color field in the query (lucene parser syntax). If the answer is yes, does this mean that "brown" is only filtered against the color field and mazda will be filtered against both the color field and the brand field?
Thanks!


Re: using lucene parser syntax with eDisMax

Posted by Chris Hostetter <ho...@fucit.org>.
: Yes on both counts. Although it takes a bit of practice, if you add
: &debug=query to the query you'll see a section of the
: response showing you exactly what the resulting query is after
: all the rules are applied.

In addition, something else about edismax that you might find useful (but 
isn't immediatley obvious) ...

: > The documentation at 
: > https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser 
: > says that eDisMax "supports the full Lucene query parser syntax".
: > Does this mean that a query string "color:brown^2 and mazda" is legal 
: > with eDisMax too?  Notice that I am specifying the color field in the 
: > query (lucene parser syntax). If the answer is yes, does this mean that 
: > "brown" is only filtered against the color field and mazda will be 
: > filtered against both the color field and the brand field?

...with the "uf" param, and per field "qf" overrides, you can define what 
it means when a query string contains a fieldname like "color" -- even if 
your index doesn't have a field named "color".

with something like this...

   defType=edismax
   uf=color title brand
   qf=main_color trim_color brand^5 title^10 text
   f.color.qf=main_color^3 trim_color^2
   q=color:brown mazda

..."brown" would only be searched against the main_color and 
trim_color fields (with the specified boosts) while "mazda" would be 
searched against all the fields listed in the "qf".  

As long as you use the "uf" param, it limits the "field names" (or field 
"aliases" if you use the f.foo.qf syntax) a user can specify in the "q" 
param -- so if you had all the params mentioned above, but the query was...

  q=color:brown security_level:private

...then even if you have a "security_level" field in your index, that part 
of the query string will be treated as a plain old string value and not a 
field name -- so all your qf fields will be searched for the string 
"security_level:private"



-Hoss
http://www.lucidworks.com/

Re: using lucene parser syntax with eDisMax

Posted by Erick Erickson <er...@gmail.com>.
Yes on both counts. Although it takes a bit of practice, if you add
&debug=query to the query you'll see a section of the
response showing you exactly what the resulting query is after
all the rules are applied.

Best,
Erick

On Fri, Jul 15, 2016 at 12:32 PM, Whelan, Andy <aw...@srcinc.com> wrote:
> Hello,
>
> I am using the eDisMax parser and have the following question.
> With the eDisMax parser we can pass a query, q="brown and mazda",  and configure a bunch of fields in a solrconfig.xml SearchHandler to query on as "qf". Let's say I have a SOLR schema.xml with the following fields:
> <field name="color" type="text_general" indexed="true" stored="true"/>
> <field name="brand" type="text_general" indexed="true" stored="true"/>
>
> and the following request handler in solrconfig.xml:
> <requestHandler name="/select" class="solr.SearchHandler" default="true">
>         <lst name="defaults">
>             <str name="defType">edismax</str>
>             <str name="qf">color brand</str>
>      </lst>
> </ requestHandler>
>
> This makes boosting very easy.  I can execute a query "q=brown^2.0 and mazda^3.0") against the query handler "/select" above without specifying fields in the query string.  I can do this without having to copy color and brand to a specific catch all field as I would with the "lucene" parser (which would be configured as the default field "df").
> The documentation at https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser says that eDisMax "supports the full Lucene query parser syntax".
> Does this mean that a query string "color:brown^2 and mazda" is legal with eDisMax too?  Notice that I am specifying the color field in the query (lucene parser syntax). If the answer is yes, does this mean that "brown" is only filtered against the color field and mazda will be filtered against both the color field and the brand field?
> Thanks!
>