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 2011/08/16 00:56:46 UTC

Re: defType argument weirdness

: Huh, I'm still not completely following. I'm sure it makes sense if you
: understand the underlying implemetnation, but I don't understand how 'type'
: and 'defType' don't mean exactly the same thing, just need to be expressed
: differently in different location.
	...
: prefixing "def" to "type" is not making it very clear what the difference is!
: What's "def" supposed to stand for anyway?)

	def == default.

type and defType both select a QParser, but they select the QParser for 
parsing different "levels" of sub queries.  

"type" can only be used as a localparam and it is how you instruct Solr as 
to what QParser you want it to use when parsing *that* specific query 
string.

"defType" can be used as either a top level param or as a localparam (to 
specify the default value for the "type" of QParser you want used for 
the main query string at that level.

Here's an example i just used last week in a project (isfdb-solr) that 
shows what i mean...

q={!boost b=sum(views,annualviews) defType=dismax v=$qq}

	...that's just syntactic sugar for...

q={!type=boost b=sum(views,annualviews) defType=dismax v=$qq}

The "type" localparam (of "q") says that the "q" param should be parsed 
using the "boost" QParser (which is what knows to parse the "b" param as a 
function and how to use it) regardless of whatever top level "defType" 
param might be specified.

the "defType" localparam then says that when parsing the "main" sub query 
(the "qq" param in this case) the default value assumed for the "type" 
local param should be dismax.

so if i have this...

q={!boost b=sum(M,N) defType=dismax v=$qq}&qq=XXX

that will result in "XXX" being parsed using the dismax QParser.

...but if i have this...

q={!boost b=sum(M,N) defType=dismax v=$qq}&qq={!type=lucene}XXX

...then the defType localparam is ignored and XXX is parsed using the 
lucene QParser (type overrides defType).

but defType only applies the "default" for the main query "one level" down 
... it doesn't recurse forever (and it doesn't apply to secondary query 
string parsing like "fq" or "facet.query" or the "b" function in the boost 
QParser) so if you have something like this...

q={!boost b=sum(M,N) defType=XXX v=$qq}&qq={!lucene v=$zz}&zz=CCC

that defType=XXX won't be used when parsing CCC (because it's one level 
removed)



-Hoss