New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sponsored Search #1066

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

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

This comment has been minimized.

Show comment
Hide comment
@selforganized

selforganized Jun 28, 2011

I'd like to have this feature too.

selforganized commented Jun 28, 2011

I'd like to have this feature too.

@kimchy

This comment has been minimized.

Show comment
Hide comment
@kimchy

kimchy Jun 30, 2011

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@bjfish

bjfish 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.

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

This comment has been minimized.

Show comment
Hide comment
@spinscale

spinscale Sep 7, 2012

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);

Member

spinscale commented Sep 7, 2012

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

This comment has been minimized.

Show comment
Hide comment
@humbucker

humbucker Sep 17, 2012

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?

humbucker commented Sep 17, 2012

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

This comment has been minimized.

Show comment
Hide comment
@clintongormley

clintongormley Sep 17, 2012

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
                  }
               }
            }
         ]
      }
   }
}
'
Member

clintongormley commented Sep 17, 2012

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