lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Questions about LocalParams syntax
Date Thu, 29 Sep 2011 00:32:42 GMT

: 1.)  How should I deal with repeating parameters?  If I use multiple 
: boost queries, it seems that only the last one listed is used...  for 
: example:
: ((_query_:"{!dismax qf=\"title^500 author^300 allfields\" bq=\"format:Book^50\" bq=\"format:Journal^150\"}test"))

Hmmm... that's either a bug or a silly limitation in the local params 
parsing -- I've file a Jira for it but i have no idea what the fix is (or 
if it was intentional for some odd reason)

...if you are interested in dig into the code to see what the cause might 
be and helping to work on a patch that would be awesome.

: 2.)  What is the proper way to escape quotes?  Since there are multiple 
: nested layers of double quotes, things get ugly and it's easy to end up 
: with syntax errors.  I found that this syntax doesn't cause an error:
: ((_query_:"{!dismax qf=\"title^500 author^300 allfields\"  bq=\"format:\\\"Book\\\"^50\"

backslash escaping should work, but you need to keep in mind that both the 
LocalParam syntax and most query parsers treat '"' and '\' as significant 
characters, so you may have to escape them more times then you think

For instance, even w/o local params, if you wanted a bq that contained a 
literal '"', you'd need to escape it for the lucene query parser...

bq=foo_s:inner\"quote OR foo_s:other

if you then wanted to use that bq as a quoted local param, you'd need to 
escape both the '\' and the original '"' again ...

q={!dismax bq="foo_s:inner\\\"quote OR foo_s:other"}foo

...and if you then wanted to use that entire {!dismax ... } string inside 
of a quoted expression using the "_query_" hook of the Lucene QParser 
(which is what it looks like you are doig) you would need to escape *all* 
of those '\' and '"' characters once more....

q=bob OR _query_:"{!dismax bq=\"foo_s:inner\\\\\\\"quote OR foo_s:other\"}foo"

...and it should work (it does for me)

But the other thing you can do to make your life a *lot* simpler is to 
leverage the parameter derefrencing and put each logical query string into 
it's own parameter...

    q=bob OR _query_:"{!dismax bq=$myBq}foo"
  & myBq=foo_s:inner\"quote OR foo_s:other

...or really make youre life easy...

  & q=bob OR _query_:"{!dismax bq=$myBq v=$qq}"
  & myBq=foo_s:inner\"quote OR foo_s:other


View raw message