首页 新闻 会员 周边 捐助

es 单字段多分词器时,textField.keyword无法高亮

0
悬赏园豆:20 [已解决问题] 解决于 2021-01-29 10:53

起因:
针对A字段,既需要做分词处理,有需要做聚合统计处理,因此为这个字段配置了多个类型,index和mapping如下

index

"analysis": {
        "analyzer": {
          "comma_analyzer": {
            "tokenizer": "comma"
          },
          "pinyin_analyzer": {
            "tokenizer": "my_pinyin"
          }
        },
        "tokenizer": {
          "comma": {
            "pattern": ",",
            "type": "pattern"
          },
          "my_pinyin": {
            "keep_none_chinese_in_first_letter": "true",
            "lowercase": "true",
            "first_letter": "prefix",
            "keep_original": "true",
            "remove_duplicated_term": "true",
            "keep_first_letter": "true",
            "keep_separate_first_letter": "true",
            "trim_whitespace": "true",
            "type": "pinyin",
            "keep_none_chinese": "true",
            "limit_first_letter_length": "16",
            "keep_full_pinyin": "true"
          }
        }
      }

mapping

"mappings": {
    "service": {
      "properties": {
        "关于中心": {
          "analyzer": "ik_max_word",
          "type": "text",
          "fields": {
            "comma": {
              "fielddata": true,
              "analyzer": "comma_analyzer",
              "type": "text"
            },
            "suggest": {
              "max_input_length": 50,
              "analyzer": "pinyin_analyzer",
              "preserve_position_increments": true,
              "type": "completion",
              "preserve_separators": true
            },
            "keyword": {
              "type": "keyword"
            }
          }
        }
      }
    }
  },

接下来问题出现了,在高亮检索时,使用.keyword进行精确检索和直接使用ik_max_word检索时,【.keyword】不返回高亮字段,请问有大佬知道为什么吗


使用【.keyword】

直接分词

代码羡的主页 代码羡 | 初学一级 | 园豆:69
提问于:2021-01-29 10:25
< >
分享
最佳答案
0

highlight里面加个关于中心.keyword

收获园豆:20
slowstart | 小虾三级 |园豆:525 | 2021-01-29 10:30

当头一棒,醍醐灌顶,恍然大悟

代码羡 | 园豆:69 (初学一级) | 2021-01-29 10:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册