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 Wangsheng Mei <ha...@gmail.com> on 2010/01/19 06:26:39 UTC

How can I boost bq in FieldQParserPlugin?

Hi, ALL.

My original query is:
http://myhost:8080/solr/select?q=ipod&*bq=userId:12345^0.5*
&fq=&start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&debugQuery=on&explainOther=&hl.fl=

It works this way.
But I would like to place bq phrase in the default solrconfig.xml
configuration to make the query string more brief, so I did the following?
http://myhost:8080/solr/select?q=ipod&*bq={!field f=userId v=$qq}&qq=12345*
&fq=&start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&debugQuery=on&explainOther=&hl.fl=

However, filedQueryParser doesn't accespt a boost parameter, then what shall
I do?

Thanks in advance.




-- 
梅旺生

Re: How can I boost bq in FieldQParserPlugin?

Posted by Chris Hostetter <ho...@fucit.org>.
: q=ipod&bq={!dismax qf=userId^0.5 v=$qq bq=}&qq=12345&qt=dismax&debugQuery=on
: 
: I try to debug the above query, it turned out to be as:
: +DisjunctionMaxQuery((content:ipod | title:ipod^4.0)~0.01) ()
: +DisjunctionMaxQuery((userId:12345^0.5)~0.01)

...hmmm, i'm not sure why that's happening, but it certianly seems like a 
bug -- i ust have no idea what that bug is.  

the inner dismax parser should definitely be producing a query where the 
DisjunctionMaxQuery for "12345" is "mandatory" but that mandatory clause 
should be wrapped inside of another boolean query which should be added to 
the outermost query as an "optional" clause.

somewhere that BooleanQuery produced by the inner dismax parser is getting 
thrown away ... hmmm, actually that this is a neccessary behavior of
DismaxQParser for some cases (that it sheds it's own outermost 
BooleanQuery when not needed), but in this case it's screwing you because 
it doesn't realize you really do need it.

does this owrk better? ...

q=ipod&bq={!dismax qf=userId^0.5 v=$qq bq=*:*^0}&qq=12345&qt=dismax&debugQuery=on

...it's kind of kludgy, but it should garuntee you that wrapping 
BooleanQuerry is preserved.



-Hoss


Re: How can I boost bq in FieldQParserPlugin?

Posted by Wangsheng Mei <ha...@gmail.com>.
Although infinite recursion is disappeared,  there is another problem.

q=ipod&bq={!dismax qf=userId^0.5 v=$qq bq=}&qq=12345&qt=dismax&debugQuery=on

I try to debug the above query, it turned out to be as:
+DisjunctionMaxQuery((content:ipod | title:ipod^4.0)~0.01) ()
+DisjunctionMaxQuery((userId:12345^0.5)~0.01)

see, the second(embeded) DisMax is marked as *Mandatory*, thus the purpose
of boosting the main query cannot be achieved.
Apparently, this is not it's expected to be.

Any ideas?


2010/1/29 Wangsheng Mei <ha...@gmail.com>

> nice trick, Yonik.[?]
>
> 2010/1/29 Yonik Seeley <yo...@lucidimagination.com>
>
> 2010/1/28 Wangsheng Mei <ha...@gmail.com>:
>> > q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax
>> >
>> > I've tried your suggested query above, unfortunately, it does not work
>> out.
>> > I glanced a bit on the error message, the "Infinite Recursion" error
>> seems
>> > that dismax query parser are adding bq multiple times.
>>
>> That is a problem...  if bq is a dismax, and part of dismax is the bq
>> param, you do get infinite recursion.
>>
>> One way around it is to define any args that could cause infinite
>> recursion in the embedded dismax query (namely the bq param).
>> So try
>> q=ipod&bq={!dismax qf=userId^0.5 v=$qq bq=}&qq=12345&qt=dismax
>>
>> Note: I just added an empty bq param to the nested dismax query.
>>
>> -Yonik
>> http://www.lucidimagination.com
>>
>
>
>
> --
> 梅旺生
>



-- 
梅旺生

Re: How can I boost bq in FieldQParserPlugin?

Posted by Wangsheng Mei <ha...@gmail.com>.
nice trick, Yonik.[?]

2010/1/29 Yonik Seeley <yo...@lucidimagination.com>

> 2010/1/28 Wangsheng Mei <ha...@gmail.com>:
> > q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax
> >
> > I've tried your suggested query above, unfortunately, it does not work
> out.
> > I glanced a bit on the error message, the "Infinite Recursion" error
> seems
> > that dismax query parser are adding bq multiple times.
>
> That is a problem...  if bq is a dismax, and part of dismax is the bq
> param, you do get infinite recursion.
>
> One way around it is to define any args that could cause infinite
> recursion in the embedded dismax query (namely the bq param).
> So try
> q=ipod&bq={!dismax qf=userId^0.5 v=$qq bq=}&qq=12345&qt=dismax
>
> Note: I just added an empty bq param to the nested dismax query.
>
> -Yonik
> http://www.lucidimagination.com
>



-- 
梅旺生

Re: How can I boost bq in FieldQParserPlugin?

Posted by Yonik Seeley <yo...@lucidimagination.com>.
2010/1/28 Wangsheng Mei <ha...@gmail.com>:
> q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax
>
> I've tried your suggested query above, unfortunately, it does not work out.
> I glanced a bit on the error message, the "Infinite Recursion" error seems
> that dismax query parser are adding bq multiple times.

That is a problem...  if bq is a dismax, and part of dismax is the bq
param, you do get infinite recursion.

One way around it is to define any args that could cause infinite
recursion in the embedded dismax query (namely the bq param).
So try
q=ipod&bq={!dismax qf=userId^0.5 v=$qq bq=}&qq=12345&qt=dismax

Note: I just added an empty bq param to the nested dismax query.

-Yonik
http://www.lucidimagination.com

Re: How can I boost bq in FieldQParserPlugin?

Posted by Wangsheng Mei <ha...@gmail.com>.
Is it problematic when I use dismax as additional boost query with bq params
of upper level dismax query?

My purpose is very simple, I wanna use dismax query to search title and
content text fields while I still wanna boost it with another field value
which is the original intetion why the bq params is designed, right?

Does anyone face the same problem?

2010/1/29 Wangsheng Mei <ha...@gmail.com>

> Hi, Chris, thanks for suggestions.
>
> q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax
>
> I've tried your suggested query above, unfortunately, it does not work out.
> I glanced a bit on the error message, the "Infinite Recursion" error seems
> that dismax query parser are adding bq multiple times.
>
> *org.apache.lucene.queryParser.ParseException: Infinite Recursion detected
>> parsing query '1014546').*
>>         at
>> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>>         at
>> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>>         at
>> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>>         at
>> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>>         at
>> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>>         at
>> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>>         at
>> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>>         at
>> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>>
>
> 2010/1/27 Chris Hostetter <ho...@fucit.org>
>
>
>> : My original query is:
>> : http://myhost:8080/solr/select?q=ipod&*bq=userId:12345^0.5*
>> :
>> &fq=&start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&debugQuery=on&explainOther=&hl.fl=
>>
>> : But I would like to place bq phrase in the default solrconfig.xml
>> : configuration to make the query string more brief, so I did the
>> following?
>> : http://myhost:8080/solr/select?q=ipod&*bq={!field<http://myhost:8080/solr/select?q=ipod&*bq=%7B%21field>f=userId v=$qq}&qq=12345*
>>
>> : However, filedQueryParser doesn't accespt a boost parameter, then what
>> shall
>>
>> ...the issue is not that "filedQueryParser doesn't accespt a boost
>> parameter" the problem is that the weight syntax from your orriginal bq
>> (the "^0.5" part) is actaul syntax from the standard parser -- and you
>> arent' using tha parser any more (the distinction between query syntax and
>> params is significant)
>>
>> I haven't tried this, but i think it might do what you want...
>>
>> q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax
>>
>> ...but you might have to put other blank params inside that {!dismax}
>> block to keep them from getting inherited formthe outer query (i can't
>> remember how that logic works off the top of my head)
>>
>>
>> -Hoss
>>
>>
>
>
> --
> 梅旺生
>



-- 
梅旺生

Re: How can I boost bq in FieldQParserPlugin?

Posted by Wangsheng Mei <ha...@gmail.com>.
Hi, Chris, thanks for suggestions.

q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax

I've tried your suggested query above, unfortunately, it does not work out.
I glanced a bit on the error message, the "Infinite Recursion" error seems
that dismax query parser are adding bq multiple times.

*org.apache.lucene.queryParser.ParseException: Infinite Recursion detected
> parsing query '1014546').*
>         at
> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>         at
> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>         at
> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>         at
> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>         at
> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>         at
> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>         at
> org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:75)
>         at
> org.apache.solr.search.DisMaxQParser.addBoostQuery(DisMaxQParser.java:107)
>

2010/1/27 Chris Hostetter <ho...@fucit.org>

>
> : My original query is:
> : http://myhost:8080/solr/select?q=ipod&*bq=userId:12345^0.5*
> :
> &fq=&start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&debugQuery=on&explainOther=&hl.fl=
>
> : But I would like to place bq phrase in the default solrconfig.xml
> : configuration to make the query string more brief, so I did the
> following?
> : http://myhost:8080/solr/select?q=ipod&*bq={!field<http://myhost:8080/solr/select?q=ipod&*bq=%7B%21field>f=userId v=$qq}&qq=12345*
>
> : However, filedQueryParser doesn't accespt a boost parameter, then what
> shall
>
> ...the issue is not that "filedQueryParser doesn't accespt a boost
> parameter" the problem is that the weight syntax from your orriginal bq
> (the "^0.5" part) is actaul syntax from the standard parser -- and you
> arent' using tha parser any more (the distinction between query syntax and
> params is significant)
>
> I haven't tried this, but i think it might do what you want...
>
> q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax
>
> ...but you might have to put other blank params inside that {!dismax}
> block to keep them from getting inherited formthe outer query (i can't
> remember how that logic works off the top of my head)
>
>
> -Hoss
>
>


-- 
梅旺生

Re: How can I boost bq in FieldQParserPlugin?

Posted by Chris Hostetter <ho...@fucit.org>.
: My original query is:
: http://myhost:8080/solr/select?q=ipod&*bq=userId:12345^0.5*
: &fq=&start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&debugQuery=on&explainOther=&hl.fl=

: But I would like to place bq phrase in the default solrconfig.xml
: configuration to make the query string more brief, so I did the following?
: http://myhost:8080/solr/select?q=ipod&*bq={!field f=userId v=$qq}&qq=12345*

: However, filedQueryParser doesn't accespt a boost parameter, then what shall

...the issue is not that "filedQueryParser doesn't accespt a boost 
parameter" the problem is that the weight syntax from your orriginal bq 
(the "^0.5" part) is actaul syntax from the standard parser -- and you 
arent' using tha parser any more (the distinction between query syntax and 
params is significant)

I haven't tried this, but i think it might do what you want...

q=ipod&bq={!dismax qf=userId^0.5 v=$qq}&qq=12345&qt=dismax

...but you might have to put other blank params inside that {!dismax} 
block to keep them from getting inherited formthe outer query (i can't 
remember how that logic works off the top of my head)


-Hoss