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 common terms query #5258

Closed
spigene opened this issue Feb 25, 2014 · 1 comment · Fixed by #5273
Closed

Add support of field boost in common terms query #5258

spigene opened this issue Feb 25, 2014 · 1 comment · Fixed by #5273

Comments

@spigene
Copy link

spigene commented Feb 25, 2014

As for now, ES ignores field level boost factors specified in mapping during computation of documents' score for common terms query.
This places certain restrictions on the client of ES.
E.g., the client has to specify different boost factors manually if he want to have distinct scores for the same term retrieved from two fields.
This quickly becomes unmanageable if the client has no direct control over search fields or if this number grows fast.
The absence of the described functionally looks especially weird comparing to the way how regular terms query works (it does honor field level boosts, see below).

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 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 common terms query

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

The first query (step 4) works as expected -- document with id equal to 2 has higher score.
The result of second query (step 5) is opposite.

@s1monw
Copy link
Contributor

s1monw commented Feb 26, 2014

ok I see the problem here I guess I have to fix that in lucene as well.... thanks for reporting this

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

Successfully merging a pull request may close this issue.

2 participants