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 ?
Thanks for reporting @Eusebiu-Biroas ! This is a bug in Lucene, I opened https://issues.apache.org/jira/browse/LUCENE-8182 to fix it.
With pleasure, thank you too @jimczi :) .
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.
This is a big deal for my company, any update on when the fix will be released?
Hello, we also need these working .. any workaround on demoting results?
Most helpful comment
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.