Skip to content
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

Add support of field boost in prefix query #5418

Closed
spigene opened this issue Mar 13, 2014 · 2 comments
Closed

Add support of field boost in prefix query #5418

spigene opened this issue Mar 13, 2014 · 2 comments

Comments

@spigene
Copy link

spigene commented Mar 13, 2014

ES ignores field level boost factors specified in mapping when computing documents' score for query string rewritten to prefix query.

Sample setup:

1. Create index and mapping.

curl -XPUT 'http://localhost:9200/messages/'
curl -XPUT 'http://localhost:9200/messages/message/_mapping' -d '
{
    "message" : {
        "properties" : {
            "message" : {"type" : "string", "store" : true },
            "comment" : {"type" : "string", "store" : true , "boost" : 5.0 }
        }
    }
}'

2. Create sample docs

curl -XPUT 'http://localhost:9200/messages/message/1' -d '{
    "user" : "user1",
    "message" : "test message",
    "comment" : "whatever"
}'

curl -XPUT 'http://localhost:9200/messages/message/2' -d '{
    "user" : "user2",
    "message" : "hello world",
    "comment" : "test comment"
}'

3. Wait for ES to be synced

curl -XPOST 'http://localhost:9200/messages/_refresh' 

4. Search in default catch-all field using query string rewritten to term query

curl -XPOST 'http://localhost:9200/messages/_search' -d '{ "query" : { "query_string" : { "query" : "test" } } , "explain" : true }' | python -mjson.tool

5. Search in default catch-all field using query string rewritten to prefix query

curl -XPOST 'http://localhost:9200/messages/_search' -d '{ "query" : { "query_string" : { "query" : "tes*" , "rewrite" : "top_terms_boost_10" } } , "explain" : true }' | python -mjson.tool

The first query (step 4) works as expected -- document with id equal to 2 has higher score.
The second query (step 5) returns two documents with equal score.
@crowleym
Copy link

@s1monw would your fix for #5258 also apply in this case?
Thanks.

@clintongormley
Copy link
Contributor

Hi @ei82

Sorry it has taken a while to get to this issue. You are using the wrong rewrite method - instead of top_terms_boost_10 (which applies a constant boost) you want top_terms_10, which takes the actual term weights into account.

See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-term-rewrite.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants