lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan McKinley (JIRA)" <>
Subject [jira] Updated: (SOLR-418) Editorial Query Boosting Component
Date Tue, 27 Nov 2007 17:46:43 GMT


Ryan McKinley updated SOLR-418:

    Attachment: SOLR-418-QueryBoosting.patch

Here is a first draft that includes recent changes to SOLR-281.  This is incomplete and is
posted to get early feedback and advice.

This component loads a file and builds a map of queries to special documents.  The format
 <query text="XXXX">
  <doc id="1" priority="1" />
 <query text="YYYY">
  <doc id="1" priority="1" />
  <doc id="2" priority="3" />
 <query text="ZZZZ">
  <doc id="1" priority="1" />
  <doc id="2" priority="3" />
  <doc id="3" priority="5" />

for the query "YYYY", document 1 should be in position 1, document 2 in position 3.
I considered a .csv style format: 
but I think the XML equivalent will be easier to edit/maintain.

The search handler is configured with:

<searchComponent name="boost" class="org.apache.solr.handler.component.QueryBoostingComponent"
    <str name="analyzer">string</str>
    <str name="boosts">boost.xml</str>
  <requestHandler name="/boost" class="solr.SearchHandler">
    <arr name="last-components">

The <str name="analyzer">string</str> bit chooses a fieldType (from schema.xml)
and uses that to normalize input strings.  This lets us reuse existing lowercase/trim/pattern/etc

For sorting, I think the best approach is to use a custom sort when sorting by score.  (This
isn't implemented yet)

Currently for a matching query, this converts the query using:
      // Build a query to match the forced documents:
      // (id:1 id:2 id:3 id:4 id:5)^0
      BooleanQuery boosted = new BooleanQuery( true );
      for( Booster b : booster ) {
        TermQuery tq = new TermQuery( new Term( idField, ) );
        boosted.add( tq, BooleanClause.Occur.SHOULD );
      boosted.setBoost( 0 ); // don't affect the score
      // Change the query to insert forced documents
      BooleanQuery newq = new BooleanQuery( true );
      newq.add( query, BooleanClause.Occur.SHOULD );
      newq.add( boosted, BooleanClause.Occur.SHOULD );
      builder.setQuery( newq );

For debugging, check:

Any feedback would be great!

> Editorial Query Boosting Component
> ----------------------------------
>                 Key: SOLR-418
>                 URL:
>             Project: Solr
>          Issue Type: New Feature
>          Components: search
>            Reporter: Ryan McKinley
>             Fix For: 1.3
>         Attachments: SOLR-418-QueryBoosting.patch
> For a given query string, a human editor can say what documents should be important.
 This is related to a lucene discussion:
> Ideally, the position could be determined explicitly by the editor - otherwise increasing
the boost is probably sufficient.
> This patch uses the Search Component framework to inject custom document boosting into
the standard SearchHandler.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message