MultiSearchHandler - Boosting results of a Query
Hello all, I am making multiple queries in a single url and trying to boost the value of a field in the 2nd based on the results of the 1st. To achieve this, my function query should be able to have access to the response of the first query. However, QParser and QParserPlugin only accepts req parameter and does not have any idea about the response. In a nutshell, all I am trying to do is that, during a serial execution of chain of queries represented by a single url( https://issues.apache.org/jira/browse/SOLR-1093), I am trying to influence the results of the second query with the results of the first query. To make the function queries ResponseAware, there are two options: *Option 1: Make all the QueryParsers ResponseAware* For this the following changes seem to be inevitable 1. Change/overload the createParser definition of QParserPlugin to include SolrQueryResponse createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryResponse rsp) - createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, SolrQueryResponse rsp) 2. Make similar changes to the getParser function in QPareser *Option 2: Make FunctionQueryParser alone ResponseAware* For this, following changes need to be made 1. Overload the FunctionQueryParserPlugin's create method with the following signature createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, SolrQueryResponse rsp) 2. Overload the getParser methong in QParser to permit the extra SolrResponse parameter and invoke this call wherever necessary. Once the parser is response aware, its easy for the components to grab the response and use them. This change to interface would mandate changes across the various components of SOLR that use all the different kind of parsers but I think this would be a useful feature as it has been requested by different people at various times. I would appreciate any kind of suggestions/feedback. Also, I would be more than happy to discuss if there are anyother way of doing the same.
Re: MultiSearchHandler - Boosting results of a Query
Clarification: Once the parser is response aware, its easy for the components to grab the response and use them. In the context of function queries, by components, I mean various Functions that has been extended from ValueSource. On Thu, Sep 13, 2012 at 3:02 PM, Karthick Duraisamy Soundararaj karthick.soundara...@gmail.com wrote: Hello all, I am making multiple queries in a single url and trying to boost the value of a field in the 2nd based on the results of the 1st. To achieve this, my function query should be able to have access to the response of the first query. However, QParser and QParserPlugin only accepts req parameter and does not have any idea about the response. In a nutshell, all I am trying to do is that, during a serial execution of chain of queries represented by a single url( https://issues.apache.org/jira/browse/SOLR-1093), I am trying to influence the results of the second query with the results of the first query. To make the function queries ResponseAware, there are two options: *Option 1: Make all the QueryParsers ResponseAware* For this the following changes seem to be inevitable 1. Change/overload the createParser definition of QParserPlugin to include SolrQueryResponse createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryResponse rsp) - createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, SolrQueryResponse rsp) 2. Make similar changes to the getParser function in QPareser *Option 2: Make FunctionQueryParser alone ResponseAware* For this, following changes need to be made 1. Overload the FunctionQueryParserPlugin's create method with the following signature createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, SolrQueryResponse rsp) 2. Overload the getParser methong in QParser to permit the extra SolrResponse parameter and invoke this call wherever necessary. Once the parser is response aware, its easy for the components to grab the response and use them. This change to interface would mandate changes across the various components of SOLR that use all the different kind of parsers but I think this would be a useful feature as it has been requested by different people at various times. I would appreciate any kind of suggestions/feedback. Also, I would be more than happy to discuss if there are anyother way of doing the same.
Re: MultiSearchHandler - Boosting results of a Query
1. please explain how exactly boost the value of a field in the 2nd based on the results of the 1st.. Please provide sample queries, docs and results. 2. introducing such chaining concern aka * ResponseAware* seems absolutely doubtful for me. 3. are you sure you are aware of tricks like http://wiki.apache.org/solr/SolrRelevancyFAQ#How_do_I_give_a_negative_.28or_very_low.29_boost_to_documents_that_match_a_query.3F and http://wiki.apache.org/solr/DisMaxQParserPlugin#bq_.28Boost_Query.29 and http://wiki.apache.org/solr/QueryElevationComponent On Thu, Sep 13, 2012 at 11:09 PM, Karthick Duraisamy Soundararaj karthick.soundara...@gmail.com wrote: Clarification: Once the parser is response aware, its easy for the components to grab the response and use them. In the context of function queries, by components, I mean various Functions that has been extended from ValueSource. On Thu, Sep 13, 2012 at 3:02 PM, Karthick Duraisamy Soundararaj karthick.soundara...@gmail.com wrote: Hello all, I am making multiple queries in a single url and trying to boost the value of a field in the 2nd based on the results of the 1st. To achieve this, my function query should be able to have access to the response of the first query. However, QParser and QParserPlugin only accepts req parameter and does not have any idea about the response. In a nutshell, all I am trying to do is that, during a serial execution of chain of queries represented by a single url( https://issues.apache.org/jira/browse/SOLR-1093), I am trying to influence the results of the second query with the results of the first query. To make the function queries ResponseAware, there are two options: *Option 1: Make all the QueryParsers ResponseAware* For this the following changes seem to be inevitable 1. Change/overload the createParser definition of QParserPlugin to include SolrQueryResponse createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryResponse rsp) - createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, SolrQueryResponse rsp) 2. Make similar changes to the getParser function in QPareser *Option 2: Make FunctionQueryParser alone ResponseAware* For this, following changes need to be made 1. Overload the FunctionQueryParserPlugin's create method with the following signature createParser(string qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req, SolrQueryResponse rsp) 2. Overload the getParser methong in QParser to permit the extra SolrResponse parameter and invoke this call wherever necessary. Once the parser is response aware, its easy for the components to grab the response and use them. This change to interface would mandate changes across the various components of SOLR that use all the different kind of parsers but I think this would be a useful feature as it has been requested by different people at various times. I would appreciate any kind of suggestions/feedback. Also, I would be more than happy to discuss if there are anyother way of doing the same. -- Sincerely yours Mikhail Khludnev Tech Lead Grid Dynamics http://www.griddynamics.com mkhlud...@griddynamics.com
Re: boosting results by a query?
found something that works great! in 3.1+ we can sort by a function query, so: sort=query({!lucene v='field:value'}) desc, score desc will put everything that matches 'field:value' first, then order the rest by score check: http://wiki.apache.org/solr/FunctionQuery#Sort_By_Function On Fri, Feb 11, 2011 at 4:31 PM, Ryan McKinley ryan...@gmail.com wrote: I have an odd need, and want to make sure I am not reinventing a wheel... Similar to the QueryElevationComponent, I need to be able to move documents to the top of a list that match a given query. If there were no sort, then this could be implemented easily with BooleanQuery (i think) but with sort it gets more complicated. Seems like I need: sortSpec.setSort( new Sort( new SortField[] { new SortField( something that only sorts results in the boost query ), new SortField( the regular sort ) })); Is there an existing FieldComparator I should look at? Any other pointers/ideas? Thanks ryan
boosting results by a query?
I have an odd need, and want to make sure I am not reinventing a wheel... Similar to the QueryElevationComponent, I need to be able to move documents to the top of a list that match a given query. If there were no sort, then this could be implemented easily with BooleanQuery (i think) but with sort it gets more complicated. Seems like I need: sortSpec.setSort( new Sort( new SortField[] { new SortField( something that only sorts results in the boost query ), new SortField( the regular sort ) })); Is there an existing FieldComparator I should look at? Any other pointers/ideas? Thanks ryan
Re: boosting results by a query?
We are currently a Lucene shop, the way we do it (currently) is to have these results come from a database table (where it is available in rank order). We want to move to Solr, so what I plan on doing to replicate this functionality is to write a custom request handler that will do the database query and put the results on the top of the search results before the SolrIndexSearcher is invoked. -sujit On Fri, 2011-02-11 at 16:31 -0500, Ryan McKinley wrote: I have an odd need, and want to make sure I am not reinventing a wheel... Similar to the QueryElevationComponent, I need to be able to move documents to the top of a list that match a given query. If there were no sort, then this could be implemented easily with BooleanQuery (i think) but with sort it gets more complicated. Seems like I need: sortSpec.setSort( new Sort( new SortField[] { new SortField( something that only sorts results in the boost query ), new SortField( the regular sort ) })); Is there an existing FieldComparator I should look at? Any other pointers/ideas? Thanks ryan