Sponsored Search #1066

Closed
bjfish opened this Issue Jun 27, 2011 · 6 comments

Projects

None yet

6 participants

@bjfish
bjfish commented Jun 27, 2011

This is a feature request for a "Sponsored Search" feature similar to the Query Elevation component in Solr: http://wiki.apache.org/solr/QueryElevationComponent.

@selforganized

I'd like to have this feature too.

@kimchy
Member
kimchy commented Jun 30, 2011

Not a big fan of static files representing elevation, would like to solve it in a different manner (still thinking on it). Though, this specific feature should not be too difficult to implement, also as a plugin with a custom native script that does that.

@bjfish
bjfish commented Jun 30, 2011

I am also not a fan of static files and was hoping it could be configured similar to the settings api:
$ curl -XPUT 'http://localhost:9200/${index}/' -d '{
"sponsor" : {
"${queryText}" : ["${result1}","${result2}"]
}
}'

with a corresponding GET. Others may want a per type level configuration too.

@spinscale
Member

You can actually achieve this behaviour already if you want. Add a field for some sort of rating (with values -1, -2, 1, 2) for rating up and change your query a bit... (might not be the most performant solution but works for us)

BoolQueryBuilder query = QueryBuilders.boolQuery();
query.should(QueryBuilders.customBoostFactorQuery(QueryBuilders.fieldQuery("yourField", "2")).boostFactor(HIGH_UP_BOOST));
query.should(QueryBuilders.customBoostFactorQuery(QueryBuilders.fieldQuery("yourField", "1")).boostFactor(UP_BOOST));
query.should(QueryBuilders.customBoostFactorQuery(QueryBuilders.fieldQuery("yourField", "-1")).boostFactor(NEG_BOOST));
query.should(QueryBuilders.customBoostFactorQuery(QueryBuilders.fieldQuery("yourField", "-2")).boostFactor(HIGH_NEG_BOOST));

query.must(your_normal_query);

@humbucker

Did this one go anywhere @kimchy? We're looking at a similar problem. Any thoughts on performant approaches that would allow us to respect bool and filtered?

@clintongormley
Member

This is easy to do with http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html

curl -XGET 'http://127.0.0.1:9200/_all/_search?pretty=1'  -d '
{
   "query" : {
      "custom_filters_score" : {
         "query" : {
            "text" : {
               "content" : "foo bar"
            }
         },
         "filters" : [
            {
               "boost" : "100",
               "filter" : {
                  "term" : {
                     "sponsored" : true
                  }
               }
            }
         ]
      }
   }
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment