O aumento do tempo de consulta do Elasticsearch produz resultado em ordem inadequada
O resultado da pesquisa ES para a palavra-chave de pesquisa fornecidaone two three
parece estar errado após a aplicaçãoboost
recurso por palavra-chave. Ajude-me a modificar minha consulta "defeituosa" para obter o "resultado esperado" abaixo, como descrevi. Estou no ES1.7.4 com LUCENE4.10.4
Critérios de reforço -three
é considerada a palavra-chave mais importante:
word - boost
---- -----
one 1
two 2
three 3
Conteúdo do índice ES - apenas mostrando o dump do MySQL para tornar o post mais curto
mysql> SELECT id, title FROM post;
+----+-------------------+
| id | title |
+----+-------------------+
| 1 | one |
| 2 | two |
| 3 | three |
| 4 | one two |
| 5 | one three |
| 6 | one two three |
| 7 | two three |
| 8 | none |
| 9 | one abc |
| 10 | two abc |
| 11 | three abc |
| 12 | one two abc |
| 13 | one two three abc |
| 14 | two three abc |
+----+-------------------+
14 rows in set (0.00 sec)
Resultado esperado da consulta ES - O usuário está procurando one two three
. Não estou preocupado com a ordem dos recordes igualmente pontuados. Quero dizer, se os registros 6 e 13 trocam de lugar, não me importo.
+----+-------------------+
| id | title | my scores for demonstration purposes
+----+-------------------+
| 6 | one two three | (1+2+3 = 6)
| 13 | one two three abc | (1+2+3 = 6)
| 7 | two three | (2+3 = 5)
| 14 | two three abc | (2+3 = 5)
| 5 | one three | (1+3 = 4)
| 4 | one two | (1+2 = 3)
| 12 | one two abc | (1+2 = 3)
| 3 | three | (3 = 3)
| 11 | three abc | (3 = 3)
| 2 | two | (2 = 2)
| 10 | two abc | (2 = 2)
| 1 | one | (1 = 1)
| 9 | one abc | (1 = 1)
| 8 | none | <- This shouldn't appear
+----+-------------------+
14 rows in set (0.00 sec)
Resultado inesperado da consulta do ES - Infelizmente, é isso que recebo.
+----+-------------------+
| id | title | _score
+----+-------------------+
| 6 | one two three | 1.0013864
| 13 | one two three abc | 1.0013864
| 4 | one two | 0.57794875
| 3 | three | 0.5310148
| 7 | two three | 0.50929534
| 5 | one three | 0.503356
| 14 | two three abc | 0.4074363
| 11 | three abc | 0.36586377
| 12 | one two abc | 0.30806428
| 10 | two abc | 0.23231897
| 2 | two | 0.12812772
| 1 | one | 0.084527075
| 9 | one abc | 0.07408653
+----+-------------------+
Consulta ES
curl -XPOST "http://127.0.0.1:9200/_search?post_dev" -d'
{
"query": {
"bool": {
"must": {
"match": {
"title": {
"query": "one two three"
}
}
},
"should": [
{
"match": {
"title": {
"query": "one",
"boost": 1
}
}
},
{
"match": {
"title": {
"query": "two",
"boost": 2
}
}
},
{
"match": {
"title": {
"query": "three",
"boost": 3
}
}
}
]
}
},
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"from": "0",
"size": "100"
}'
Mais algumas consultas de teste:
esteinquerir não produz nenhum resultado.esteinquerir não pede corretamente como pareceaqui.