I don't have the complete answer. But I _think_ if you do one 'bq' param with multiple space-seperated directives, it will work.

And escaping is a pain. But can be made somewhat less of a pain if you realize that single quotes can sometimes be used instead of double-quotes. What I do:

_query_:"{!dismax qf='title something else'}"

So by switching between single and double quotes, you can avoid need to escape. Sometimes you still do need to escape when a single or double quote is actually in a value (say in a 'q'), and I do use backslash there. If you had more levels of nesting though... I have no idea what you'd do.

I'm not even sure why you have the internal quotes here:

bq=\"format:\\\"Book\\\"^50\"


Shouldn't that just be bq='format:Book^50', what's the extra double quotes around <<Book>>? If you don't need them, then with switching between single and double, this can become somewhat less crazy and error prone:

_query_:"{!dismax bq='format:Book^50'}"

I think. Maybe. If you really do need the double quotes in there, then I think switching between single and double you can use a single backslash there.


On 9/20/2011 9:39 AM, Demian Katz wrote:
I'm using the LocalParams syntax combined with the _query_ pseudo-field to 
build an advanced search screen (built on Solr 1.4.1's Dismax handler), but I'm 
running into some syntax questions that don't seem to be addressed by the wiki 
page here:

http://wiki.apache.org/solr/LocalParams


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"))

                 boosts Journals, but not Books.  If I reverse the order of the 
two bq parameters, then Books get boosted instead of Journals.  I can work 
around this by creating one bq with the clauses OR'ed together, but I would 
rather be able to apply multiple bq's like I can elsewhere.


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\" 
bq=\"format:\\\"Journal\\\"^150\"}test"))

                 ...but it also doesn't work correctly - the boost queries are 
completely ignored in this example.  Perhaps this is more a problem related to  
_query_ than to LocalParams syntax...  but either way, a solution would be 
great!

thanks,
Demian

Reply via email to