Я не уверен, каков ваш вариант использования, но это не то, что я бы порекомендовал вам сделать, пытаясь исправить свой показатель релевантности.Вот пример для одного из случаев, и есть несколько способов сделать это
POST /_search
{
"query":{
"bool":{
"should":[
{
"constant_score":{
"filter":{
"term":{
"color":"red"
}
},
"boost":1
}
},
{
"bool":{
"must_not":{
"term":{
"color":"red"
}
},
"boost":0
}
}
]
}
}
}
, и результат будет
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 6,
"max_score": 1,
"hits": [
{
"_index": "test",
"_type": "_doc",
"_id": "2",
"_score": 1,
"_source": {
"color": "red",
"size": "M"
}
},
{
"_index": "test",
"_type": "_doc",
"_id": "1",
"_score": 1,
"_source": {
"color": "red",
"size": "S"
}
},
{
"_index": "test",
"_type": "_doc",
"_id": "3",
"_score": 1,
"_source": {
"color": "red",
"size": "L"
}
},
{
"_index": "test",
"_type": "_doc",
"_id": "5",
"_score": 0,
"_source": {
"color": "blue",
"size": "M"
}
},
{
"_index": "test",
"_type": "_doc",
"_id": "4",
"_score": 0,
"_source": {
"color": "blue",
"size": "S"
}
},
{
"_index": "test",
"_type": "_doc",
"_id": "6",
"_score": 0,
"_source": {
"color": "blue",
"size": "L"
}
}
]
}
}