PUT th_topic
{
  "settings": {
    "analysis": {
      "analyzer": {
        "ik_pinyin_analyzer":{
          "char_filter":["html_strip"],
          "tokenizer":"keyword",
          "filter":["my_pinyin"]
        }
      },
      "filter": {
        "my_pinyin":{
          "type":"pinyin",
          "keep_full_pinyin":false,
          "keep_joined_full_pinyin":true,
          "keep_original":true,
          "keep_none_chinese":false,
          "keep_none_chinese_in_joined_full_pinyin":true
        }
      }
    }
  },
  "mappings" : {
      "properties" : {
        "topicBrowseCount" : {
          "type" : "long"
        },
        "userCode" : {
          "type" : "keyword"
        },
        "topicCommentCount" : {
          "type" : "long"
        },
        "createTime" : {
          "type" : "date"
        },
        "topicContent" : {
          "type" : "text",
          "analyzer": "ik_max_word"
        },
        "topicId" : {
          "type" : "long"
        },
        "topicLikeCount" : {
          "type" : "long"
        },
        "topicCode" : {
          "type" : "keyword"
        },
        "topicTitle" : {
          "type" : "text",
          "analyzer": "ik_max_word", 
          "search_analyzer": "ik_smart", 
          "fields" : {
            "keyword" : {
              "type" : "completion",
              "analyzer" : "ik_pinyin_analyzer",
              "search_analyzer": "keyword"
            }
          }
        },
        "updateTime" : {
          "type" : "date"
        },
        "type":{
          "type": "text",
          "fields": {
            "keyword":{
              "type": "keyword"
            }
          }
        }
      }
    }
}
创建的索引字段topicTitle使用了ik分词器,并且设置了扩展词 `题乎`,并且该索引下的数据包含有题乎的topicTitle,但是我在用DSL查询语句查询时,查不到任何结果,我的查询语句如下:
 
 
GET th_topic/_search
{
  "query": {
    "match": {
      "topicTitle": "题乎"
    }
  }
}
得到的查询结果如下图
 
																
															 
														
0 个回复