Discussion:
how to run boost query for non-dismax query parser
cyang2010
2011-03-24 02:01:47 UTC
Permalink
Hi,

I need to code some boosting logic when some field equal to some value. I
was able to get it work if using dismax query parser. However, since the
solr query will need to handle prefix or fuzzy query, therefore, dismax
query parser is not really my choice.

Therefore, i want to use standard query parser, but still have dismax's
boosting query logic. For example, this query return all the titles
regardless what the value is, however, will boost the score of those which
genres=5237:

http://localhost:8983/solr/titles/select?indent=on&start=0&rows=10&fl=*%2Cscore&wt=standard&explainOther=&hl.fl=&qt=standard&q={!boost%20b=genres:5237^2.2}*%3A*&debugQuery=on


Here is the exception i get:
HTTP ERROR: 400

org.apache.lucene.queryParser.ParseException: Expected ',' at position 6 in
'genres:5237^2.2'


I am just following the instruction on this page although the instruction
there is really to implement a boost function, instead of boosting query.
http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_boost_the_score_of_newer_documents

Thanks for your help,

cy

--
View this message in context: http://lucene.472066.n3.nabble.com/how-to-run-boost-query-for-non-dismax-query-parser-tp2723442p2723442.html
Sent from the Solr - User mailing list archive at Nabble.com.
Ahmet Arslan
2011-03-24 14:09:49 UTC
Permalink
Post by cyang2010
I need to code some boosting logic when some field equal to
some value.   I
was able to get it work if using dismax query parser. 
However, since the
solr query will need to handle prefix or fuzzy query,
therefore, dismax
query parser is not really my choice. 
Therefore, i want to use standard query parser, but still
have dismax's
boosting query logic.  For example, this query return
all the titles
regardless what the value is, however, will boost the score
of those which
http://localhost:8983/solr/titles/select?indent=on&start=0&rows=10&fl=*%2Cscore&wt=standard&explainOther=&hl.fl=&qt=standard&q={!boost%20b=genres:5237^2.2}*%3A*&debugQuery=on
HTTP ERROR: 400
org.apache.lucene.queryParser.ParseException: Expected ','
at position 6 in
'genres:5237^2.2'
BoostingQParserPlugin takes a FunctionQuery. In your case it is lucene/solr query. If you want to boost by solr/lucene query, you can add that clause as optional clause. Thats all.

q=+*:* genres:5237^2.2&q.op=OR will do the trick. Just make sure that you are using OR as a default operator.
cyang2010
2011-03-24 18:25:20 UTC
Permalink
Hi iorixxx,

Thanks for your reply. yeah, an additional query with the boost value will
work.

However, I just wonder where you get the information that BoostQParserPlugin
only handles function query?

I looked up the javadoc, and still can't get that. This is the javadoc.


Create a boosted query from the input value. The main value is the query to
be boosted.
Other parameters: b, the function query to use as the boost.


This just say if b value is specified it is a function query. I just don't
understand why dismaxParser has both bf and bq, but for BoostQParserPlugin
there is only bf equivalent.

Another question is by specifying localParameter like that in query, does it
mean to use the default LuceneQParserPlugin primarily and only use
BoostQParserPlugin for the content with the {}?

Thanks. look forward to your reply,


cy

--
View this message in context: http://lucene.472066.n3.nabble.com/how-to-run-boost-query-for-non-dismax-query-parser-tp2723442p2726422.html
Sent from the Solr - User mailing list archive at Nabble.com.
Ahmet Arslan
2011-03-24 20:37:01 UTC
Permalink
Thanks for your reply.  yeah, an additional query with
the boost value will
work.
However, I just wonder where you get the information that
BoostQParserPlugin
only handles function query?
I looked up the javadoc, and still can't get that. 
This is the javadoc.
Create a boosted query from the input value. The main value
is the query to
be boosted.
Other parameters: b, the function query to use as the
boost.
This just say if b value is specified it is a function
query.   
As you and wiki said, b is the "function query" to use as the boost.
I just don't
understand why dismaxParser has both bf and bq, but for
BoostQParserPlugin
there is only bf equivalent.
I don't know that :) However optional clauses with LuceneQParserPlugin will do the same effect as dismax's bq.
Another question is by specifying localParameter like that
in query, does it
mean to use the default LuceneQParserPlugin primarily and
only use
BoostQParserPlugin for the content with the {}?
Not only for BoostQParserPlugin.

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

http://wiki.apache.org/solr/SimpleFacetParameters#Multi-Select_Faceting_and_LocalParams
cyang2010
2011-03-24 22:08:52 UTC
Permalink
iorixxx, thanks for your reply.

Another a little bit off topic question. I looked over all the subclasses
of QParserPlugin. It seesm like most of them provide complementary parsing
to the default lucene/solr parser. Except prefixParser. What is the
intended usage of that one? The default lucene/solr parser is able to parse
prefix query. Is the intended usage with dismax parser?

--
View this message in context: http://lucene.472066.n3.nabble.com/how-to-run-boost-query-for-non-dismax-query-parser-tp2723442p2727566.html
Sent from the Solr - User mailing list archive at Nabble.com.

Loading...