搜索结果正在快递途中

es match_phrase英文分词器会报错是为啥

Elasticsearch | 作者 CurryQin | 发布于2020年11月27日 | 阅读数:2222

                "title": {
"search_analyzer": "ik_smart_ts_synonym",
"analyzer": "ik_max_word_ts_synonym",
"type": "text",
"index_options": "docs"
},
"title_en": {
"search_analyzer": "english",
"analyzer": "english",
"type": "text",
"index_options": "docs"
},
这是title_en的设置,
查询语句是:
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "苹果",
"fields": [
"title",
"title_en",
"title_ko",
"keywords"
],
"type": "best_fields",
"operator": "OR",
"slop": 0,
"prefix_length": 0,
"max_expansions": 50,
"lenient": false,
"zero_terms_query": "NONE",
"boost": 1
}
},
"should": [
{
"match_phrase": {
"title": {
"query": "苹果",
"boost": 1.5,
"slop": 0
}
}
},
{
"match_phrase": {
"title_en": {
"query": "苹果",
"boost": 1.5,
"slop": 0
}
}
},
{
"match_phrase": {
"keywords": {
"query": "苹果",
"boost": 1.5,
"slop": 0
}
}
}
],
"filter": {
"bool": {
"must": [
{
"nested": {
"path": "price",
"query": {
"term": {
"price.sales_org_id": 1
}
}
}
}
]
}
}
}
},
"from": 0,
"size": 100
}

报错提示说
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: field:[title_en] was indexed without position data; cannot run PhraseQuery",
"index_uuid": "t8mSqt2VRTOxEXmmzrTfEw",
"index": "sayweee_im_2020-11-26"
}
已邀请:

JiangJibo - 喊我雷锋

赞同来自: CurryQin

默认的index_options配置是docs_freq_position,但你指定了index_options为docs时,倒排索引就只含有docId了,你只能用_id去查询,不能用倒排索引检索了

CurryQin

赞同来自:

是我的词分词后没有position位置信息么  可是我用分词器测试了 是有position位置信息的

JiangJibo - 喊我雷锋

赞同来自:

错误信息都说明了,你的 title_en 属性只记录了docId,没有记录position,话说为什么你要设置 "index_options": "docs",默认是带上position,分词器测试时你没指定 index_options 吧,所以有position信息

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

title_en 从这个字段的设置找原因

要回复问题请先登录注册