weird behavior for Solr defType param.

207 views
Skip to first unread message

Naomi Dushay

unread,
Jul 19, 2011, 2:38:59 PM7/19/11
to blacklight-...@googlegroups.com
This is cross posted to solr-user and to hydra-tech lists.

I discovered a weird behavior with the Solr  defType parameter.  See

 http://www.lucidimagination.com/search/document/39c0e70e20853e93/deftype_argument_weirdness

I encountered this as I was trolling through my Solr logs, working out some implementation issue in a Hydra application.   It is possible this is addressed per the discussion re: Blacklight solr parameters arguments.  In case that is not true:

in  hydra-head/app/controllers/catalog_controller,

line 86:

   params = {:qt=>"search",:defType=>"dismax",:q=>"*:*",:rows=>"0",:facet=>"true", :facets=>{:fields=>Blacklight.config[:facet][:field_names]}}

should probably be

   params = {:qt=>"search",:q=>"{!defType=dismax}*:*",:rows=>"0",:facet=>"true", :facets=>{:fields=>Blacklight.config[:facet][:field_names]}}

   (there are other options, but I think the above is probably the clearest because it indicates the queryParser (defType) and the query string.)



The Solr nuts and bolts:
I thought that     defType=dismax&q=*:*   is supposed to be equivalent to  q={!defType=dismax}*:*  and also equivalent to q={!dismax}*:*

defType=dismax&q=*:*   DOESN'T WORK
<str name="rawquerystring">*:*</str>
<str name="querystring">*:*</str>
<str name="parsedquery">+() ()</str>
<str name="parsedquery_toString">+() ()</str>

leaving out the explicit query
defType=dismax     WORKS
<null name="rawquerystring"/>
<null name="querystring"/>
<str name="parsedquery">+MatchAllDocsQuery(*:*)</str>
<str name="parsedquery_toString">+*:*</str>


q={!dismax}*:*   DOESN'T WORK
<str name="rawquerystring">*:*</str>
<str name="querystring">*:*</str>
<str name="parsedquery">+() ()</str>
<str name="parsedquery_toString">+() ()</str>

leaving out the explicit query:
q={!dismax}    WORKS
<str name="rawquerystring">{!dismax}</str>
<str name="querystring">{!dismax}</str>
<str name="parsedquery">+MatchAllDocsQuery(*:*)</str>
<str name="parsedquery_toString">+*:*</str>


q={!defType=dismax}*:*    WORKS
<str name="rawquerystring">{!defType=dismax}*:*</str>
<str name="querystring">{!defType=dismax}*:*</str>
<str name="parsedquery">MatchAllDocsQuery(*:*)</str>
<str name="parsedquery_toString">*:*</str>

leaving out the explicit query:
q={!defType=dismax}    DOESN'T WORK
org.apache.lucene.queryParser.ParseException: Cannot parse '': Encountered "<EOF>" at line 1, column 0.

<requestHandler name="search" class="solr.SearchHandler" default="true">
      <lst name="defaults">
              <str name="defType">lucene</str>

              <!-- lucene params -->
              <str name="df">has_model_s</str>
              <str name="q.op">AND</str>

              <!-- dismax params -->
              <str name="mm"> 2<-1 5<-2 6<90% </str>
              <str name="q.alt">*:*</str>
              <str name="qf">text</str>
              <str name="pf">text</str>
</requestHandler>

- Naomi

Erik Hatcher

unread,
Jul 19, 2011, 3:02:53 PM7/19/11
to blacklight-...@googlegroups.com

On Jul 19, 2011, at 14:38 , Naomi Dushay wrote:

> This is cross posted to solr-user and to hydra-tech lists.
>
> I discovered a weird behavior with the Solr defType parameter. See
>
> http://www.lucidimagination.com/search/document/39c0e70e20853e93/deftype_argument_weirdness
>
> I encountered this as I was trolling through my Solr logs, working out some implementation issue in a Hydra application. It is possible this is addressed per the discussion re: Blacklight solr parameters arguments. In case that is not true:
>
> in hydra-head/app/controllers/catalog_controller,
>
> line 86:
>
> params = {:qt=>"search",:defType=>"dismax",:q=>"*:*",:rows=>"0",:facet=>"true", :facets=>{:fields=>Blacklight.config[:facet][:field_names]}}
>
> should probably be
>
> params = {:qt=>"search",:q=>"{!defType=dismax}*:*",:rows=>"0",:facet=>"true", :facets=>{:fields=>Blacklight.config[:facet][:field_names]}}

huh?! I replied on that e-mail thread answering but maybe I wasn't clear?

No. {!defType=anything} is ineffective. It doesn't control the query parser that way. Besides, *:* is not recognized by the dismax parser. But anyway, {!defType=dismax} doesn't select dismax, so you're falling back to the "lucene" query parser default and thus *:* works.

If you want to use dismax, yet make a request to match all docs, leave q empty or unspecified, and use q.alt=*:*.

Erik

Chris Beer

unread,
Jul 19, 2011, 3:06:43 PM7/19/11
to blacklight-...@googlegroups.com
I'd just note that I fixed something very similar in the blacklight_advanced_search plugin last week, to fix a bug that was only showing up under Ruby 1.9 for some reason, and I added {!lucene}*:* as the default 'q' parameter.

Chris

> --
> You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
> To post to this group, send email to blacklight-...@googlegroups.com.
> To unsubscribe from this group, send email to blacklight-develo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/blacklight-development?hl=en.
>

Jonathan Rochkind

unread,
Jul 19, 2011, 3:47:14 PM7/19/11
to blacklight-...@googlegroups.com, Naomi Dushay
I am not familiar with the Hydra configuration in question, but I'm confused about that too:

Everything I know indeed says that:

&defType=lucene&q=*:*

should do the same thing as &q={!lucene}*:*     # except URL encoded

I'm not sure why it's not.  Is it possible some other part of Solr configuration/code is putting something ELSE in the Solr LocalParams defType position?  Blacklight does support configuration of Solr LocalParams that will be injected into a 'q' by Blacklight code, perhaps that is conflicting with something in Hydra?

Oh but wait, one more confusing thing here:   I don't believe that "*:*" is actually a query understood by dismax, is it?  That query is understood by the lucene query parser, but I don't think that query is actually understood by the dismax query parser.

So I think maybe something other than you want/expect is going on here -- rather than make it recognize 'dismax', you've perhaps made it actually _ignore_ the 'dismax' part, so the query parser ends up being 'lucene' which understands *:*?

The reason the straight query "defType=dismax" (with empty 'q') works is probably that somewhere you have a dismax "q.alt" set to "*:*".   (Solr request handler defaults, Blacklight defaults, etc). "If specified, this query will be used (and parsed by default using standard query parsing syntax) when the main query string is not specified or blank."  http://wiki.apache.org/solr/DisMaxQParserPlugin#q.alt

Note that "q.alt" is a dismax thing, but it's actually parsed by 'lucene' query parser, and used only when there's an empty 'q'.

This stuff gets confusing.

Jonathan
Reply all
Reply to author
Forward
0 new messages