Context
- Elasticsearch version: 8.8.0-SNAPSHOT (Commit: 56633e0a2934b03090ab726c33e5289129c98bfe [56633e0])
- Lucene version: lucene-join-9.6.0-SNAPSHOT
I create two equals indices:
PUT /question_answer_1
{
"aliases": {
"question_answer": {}
},
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"text": { "type": "text" },
"join": {
"type": "join",
"relations": {
"question": "answer"
}
}
}
}
}
PUT /question_answer_2
{
"aliases": {
"question_answer": {}
},
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"text": { "type": "text" },
"join": {
"type": "join",
"relations": {
"question": "answer"
}
}
}
}
}
So, i populated with following data:
PUT question_answer_1/_doc/1?refresh
{
"text": "what is the first question?",
"join": { "name": "question" }
}
PUT question_answer_1/_doc/1-1?routing=1&refresh
{
"text": "this is the first response of the first question",
"join": { "name": "answer", "parent": "1" }
}
PUT question_answer_1/_doc/1-2?routing=1&refresh
{
"text": "this is the second response of the first question",
"join": { "name": "answer", "parent": "1" }
}
PUT question_answer_2/_doc/1?refresh
{
"text": "what is the first question?",
"join": { "name": "question" }
}
PUT question_answer_2/_doc/1-1?routing=1&refresh
{
"text": "this is the first response of the first question",
"join": { "name": "answer", "parent": "1" }
}
PUT question_answer_2/_doc/1-2?routing=1&refresh
{
"text": "this is the second response of the first question",
"join": { "name": "answer", "parent": "1" }
}
Problem
When i make this query:
GET question_answer/_search
{
"_source": false,
"query": {
"has_child": {
"type": "answer",
"score_mode": "max",
"query": {
"match": {
"text": "second"
}
}
}
}
}
the return is:
{
"took": 44,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 0.91568196,
"hits": [
{
"_index": "question_answer_1",
"_id": "1",
"_score": 0.91568196
},
{
"_index": "question_answer_2",
"_id": "1",
"_score": 0.91568196
}
]
}
}
If i use indices_boost
to prioritize the index question_answer_1
as following:
GET question_answer/_search
{
"indices_boost": [
{
"question_answer_1": 10
}
],
"_source": false,
"query": {
"has_child": {
"type": "answer",
"score_mode": "max",
"query": {
"match": {
"text": "second"
}
}
}
}
}
I expected that the document of _id=1
and _index=question_answer_1
return _score=9.1568196
(10 * 0.91568196), but the result is the same as before:
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 0.91568196,
"hits": [
{
"_index": "question_answer_1",
"_id": "1",
"_score": 0.91568196
},
{
"_index": "question_answer_2",
"_id": "1",
"_score": 0.91568196
}
]
}
}
Then i clonclude that the indices_boost
does not work for has_child
query. Is it right?
Debuging the Elasticsearch, i saw the following code in the GlobalOrdinalsWithScoreQuery Lucene class:
return new W(
this,
toQuery.createWeight(searcher, org.apache.lucene.search.ScoreMode.COMPLETE_NO_SCORES, 1f));
I change to
return new W(
this,
toQuery.createWeight(searcher, scoreMode, boost));
but does not work.
The toString
method of class GlobalOrdinalsWithScoreQuery shows the following string:
(GlobalOrdinalsQuery{joinField=join#questionmin=1max=2147483647fromQuery=+text:second #join:answer})^10.0