Обновление ElasticSearch после обновления
У меня есть проблема с "обновлением" в ElasticSearch v6.2.1.
Учитывая индекс "my_index" и тип "my_type", это сценарий:
Шаг 1: Запустите запрос, который возвращает 50 первых документов, в которых некоторые поля (идентификатор, адрес, информация) соответствуют параметру термина (например, ПАРИЖ).
Результат:
DOC1, DOC2, DOC3, DOC4,... DOC50
Шаг 2. Обновите поле phoneNumber в DOC1 с помощью запроса (/my_index/my_type/DOC1/_update
)
Шаг 3: Перезапустить запрос шага 1.
Результат:
DOC2, DOC3, DOC4, DOC5,... DOC1 (29-е место), .... DOC50
Как мы видим, мой измененный документ переместился на 29 место. Мой вопрос заключается в том, почему мой документ не занимает одно и то же место, зная, что phoneNumber не учитывается при моем поиске.
Я пытался обновить индекс (/my_index/_refresh
), чтобы запустить обновление после обновления с помощью "?refresh
"(даже если это по умолчанию), чтобы установить"refresh_interval
"до 1 секунды.
Есть идеи об этом поведении, я что-то забыл?
Обновление с помощью запроса (извлечение из кода Java):
{
"from": 0,
"size": 50,
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "*par*",
"fields": [
"contact.address.*^1.2",
"id^1.2",
"information.*^1.2"
],
"type": "best_fields",
"default_operator": "or",
"max_determinized_states": 10000,
"enable_position_increments": true,
"fuzziness": "AUTO",
"fuzzy_prefix_length": 0,
"fuzzy_max_expansions": 50,
"phrase_slop": 0,
"analyze_wildcard": true,
"escape": false,
"auto_generate_synonyms_phrase_query": true,
"fuzzy_transpositions": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"_source": {
"includes": [
"id",
"information.*",
"geoPosition.*"
],
"excludes": []
}
}
Обновление с выдержкой из картографии
{
"station_index_test": {
"mappings": {
"station_type": {
"properties": {
"contact": {
"properties": {
"address": {
"properties": {
"city": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"country": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"countryCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"postCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"streetLines": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"faxNumber": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phoneNumber": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"information": {
"properties": {
"localizedNames": {
"properties": {
"name-ar_AE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-ar_EG": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-bg_BG": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-bs_BA": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-ca_ES": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-cs_CZ": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-da_DK": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-de_AT": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-de_CH": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-de_DE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-el_GR": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_AT": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_AU": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_BE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_CH": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_GB": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_IE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_NZ": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-en_US": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-es_ES": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-et_EE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-fa_IR": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-fi_FI": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-fr_BE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-fr_CH": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-fr_FR": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-he_IL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-hr_HR": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-hu_HU": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-hy_AM": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-it_CH": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-it_IT": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-ja_JP": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-ko_KR": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-lt_LT": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-lv_LV": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-nl_BE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-nl_NL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-no_NO": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-pl_PL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-pt_PT": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-ro_RO": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-ru_RU": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-sk_SK": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-sl_SI": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-sq_AL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-sv_FI": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-sv_SE": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-th_TH": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-tr_TR": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-uk_UA": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name-zh_CN": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"timezone": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"services": {
"properties": {
"code": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"views": {
"type": "long"
}
}
}
}
}
}
Обновление: объяснения до и после одинаковы:
{
"value": 1.2,
"description": "max of:",
"details": [
{
"value": 1.2,
"description": "information.localizedNames.name-pt_PT.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-de_AT:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-cs_CZ.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fr_BE.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-cs_CZ:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_CH:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sl_SI.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ro_RO:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ko_KR:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ar_EG.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-uk_UA.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ko_KR.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ru_RU.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fr_CH.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fa_IR.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-es_ES:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sk_SK:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-bg_BG.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sv_FI.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_BE:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sv_SE:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sq_AL:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_IE.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-da_DK:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fi_FI.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.name:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_AU:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_AT:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fr_FR.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-el_GR:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-pt_PT:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-de_CH.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sk_SK.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-pl_PL:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-he_IL:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_NZ.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-tr_TR:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ja_JP.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-de_CH:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-uk_UA:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_US:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-de_DE:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-no_NO.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-hy_AM.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fr_BE:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ar_AE.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-et_EE.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ar_AE:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-da_DK.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.name.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-pl_PL.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-lt_LT.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fi_FI:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-lv_LV:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sv_SE.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sl_SI:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-fr_CH:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_AT.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "contact.address.city:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-bs_BA:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-es_ES.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-lv_LV.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-tr_TR.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-hu_HU:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_GB:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-hr_HR.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-de_AT.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-th_TH:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ro_RO.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_US.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sv_FI:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-zh_CN.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_NZ:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-th_TH.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ca_ES:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-el_GR.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ja_JP:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-hr_HR:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-lt_LT:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-sq_AL.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-no_NO:*paris*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-en_AU.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-bs_BA.keyword:*PARIS*^1.2",
"details": []
},
{
"value": 1.2,
"description": "information.localizedNames.name-ru_RU:*paris*^1.2",
"details": []
}
]
}
1 ответ
Оценка довольно сложна: https://www.elastic.co/guide/en/elasticsearch/reference/current/consistent-scoring.html
Как я понимаю, все документы получают одинаковый балл в вашем случае. Таким образом, при заказе по баллам точный порядок является своего рода неопределенным поведением. Когда вы обновляете документ, он переиндексируется (удаляется и вставляется снова), поэтому можно перейти в любое место в списке. Если вам нужна последовательная и предсказуемая сортировка, возможно, добавьте упорядочение по идентификатору, например, в упорядочение по _score (по умолчанию).