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

Boosting Query with negative_boost does not work as expected on 6.x #28739

Closed
eusebiu-biroas opened this issue Feb 19, 2018 · 5 comments
Closed
Assignees

Comments

@eusebiu-biroas
Copy link

Elasticsearch version : 6.x

JVM version :1.8.0

OS version : Windows 10, Kubernetes Pods

Description of the problem:
On versions 6.x it seems that Boosting Query with negative_boost does not work anymore as described in the Official Guide.
On versions 5.x it works as expected.

Steps to reproduce:

1. create index mapping:

PUT /testn1

    {
    "mappings": {
        "test": {
            "dynamic": "strict",
            "_all": {
                "enabled": false
            },
            "properties": {
                "id": {
                    "type": "keyword"
                },
                "tags": {
                    "type": "keyword"
                }
            }
        }
    }
}

2. Insert 3 documents:

PUT /testn1/test/1

{
    "id": "1",
    "tags": ["active", "first"]
}

PUT /testn1/test/2

{
    "id": "1",
    "tags": ["active", "second"]
}

PUT /testn1/test/3

{
    "id": "1",
    "tags": ["active", "third"]
}

3. Execute a search using the following query:

/testn1/_search

{
    "query": {
        "boosting": {
            "positive": {
                "term": {
                    "tags": "active"
                }
            },
            "negative": {
                "term": {
                    "tags": "second"
                }
            },
            "negative_boost": 0.2
        }
    }
}

4. No matter what values we will use for the negative query, we will get the same result:

{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 3,
        "max_score": 0.2876821,
        "hits": [{
                "_index": "testn2",
                "_type": "test",
                "_id": "2",
                "_score": 0.2876821,
                "_source": {
                    "id": "1",
                    "tags": [
                        "active",
                        "second"
                    ]
                }
            },
            {
                "_index": "testn2",
                "_type": "test",
                "_id": "1",
                "_score": 0.2876821,
                "_source": {
                    "id": "1",
                    "tags": [
                        "active",
                        "first"
                    ]
                }
            },
            {
                "_index": "testn2",
                "_type": "test",
                "_id": "3",
                "_score": 0.2876821,
                "_source": {
                    "id": "1",
                    "tags": [
                        "active",
                        "third"
                    ]
                }
            }
        ]
    }
}

I suspect that the cause may be in some code being changed in the Lucene library, BoostingQuery seems to be deprecated: https://issues.apache.org/jira/browse/LUCENE-8099. If this is the case, do we have an efficient alternative to demote results that match a given query ?

@jimczi
Copy link
Contributor

jimczi commented Feb 21, 2018

Thanks for reporting @eusebiu-biroas ! This is a bug in Lucene, I opened https://issues.apache.org/jira/browse/LUCENE-8182 to fix it.

@jimczi jimczi self-assigned this Feb 21, 2018
@eusebiu-biroas
Copy link
Author

With pleasure, thank you too @jimczi :) .

@jimczi
Copy link
Contributor

jimczi commented Feb 22, 2018

This fix will be shipped in the next minor release of 6.x (6.3), it is already fixed in Lucene so I am closing this issue.

@jimczi jimczi closed this as completed Feb 22, 2018
@BKlippel
Copy link

BKlippel commented Jun 7, 2018

This is a big deal for my company, any update on when the fix will be released?

@clizarralde
Copy link

Hello, we also need these working .. any workaround on demoting results?

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

No branches or pull requests

4 participants