Space-separation works for the qf field, but not for bq.  If I try a bq of 
"format:Book^50 format:Journal^150", I get a strange result -- I would expect 
in the case of a failed bq that either a) I would get a syntax error of some 
sort or b) I would get normal search results with no boosting applied.  
Instead, I get a successful search result containing 0 entries.  Very odd!  
Anyway, the solution that definitely works is joining the clauses with OR...  
but I'd still love to be able to specify multiple bq's separately if there's 
any way it can be done.

As for the quote issue, the problem I'm trying to solve is that my code is 
driven by configuration files, and users may specify any legal Solr bq values 
that they choose.  You're right that in some cases, I can simplify the 
situation by alternating quotes or changing the syntax...  but I don't want to 
force users into using a subset of legal Solr syntax; it would be much better 
to able to handle all legal cases in a straightforward fashion.  Admittedly, my 
example is artificial -- format:Book^50 works just as well as 
format:"Book"^50...  but suppose they wanted to boost a phrase like 
format:"Conference Proceeding"^25 -- this is a common case.  It seems like 
there should be some syntax that allows this to work in the context I am using 
it.  If not, perhaps we need to file a bug report.

In any case, thanks for taking the time to make some suggestions!  It surprises 
me that this very powerful feature of Solr is so little-documented.

- Demian

> -----Original Message-----
> From: Jonathan Rochkind [mailto:rochk...@jhu.edu]
> Sent: Tuesday, September 20, 2011 10:32 AM
> To: solr-user@lucene.apache.org
> Cc: Demian Katz
> Subject: Re: Questions about LocalParams syntax
> 
> 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