ElasticSearch v6.2.1 存在一些“ 刷新”问题。
给出一个索引“ my_index ”和一个类型“ my_type ”,这就是这种情况:
步骤1 :启动查询,返回前50个文档,其中某些字段(ID,地址,信息)与术语参数(例如PARIS)匹配
结果:
DOC1, DOC2, DOC3, DOC4, ... DOC50
步骤2 :使用查询(/my_index/my_type/DOC1/_update
)更新DOC1电话号码字段
第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": []
}
]
}
答案 0 :(得分:0)
计分有些复杂:https://www.elastic.co/guide/en/elasticsearch/reference/current/consistent-scoring.html
据我了解,在您的情况下,所有文档的得分均相同。因此,按分数排序时,确切的顺序属于不确定行为。当您更新文档时,它会重新编制索引(删除并再次插入),因此可以在列表中的任何位置。如果您需要一致且可预测的排序,则可以将按ID排序(例如)添加到_score(默认)排序中。