elasticsearch 设置mapping一个字段用多个分词器

PUT enterpriseextend/_mapping/enterpriseextend
{
  "properties": {
    "id": {
      "type": "long"
    },
    "entName": {
      "type": "text", 
      "analyzer": "ikIndexAnalyzer",
      "fields": {
        "ngram": {
          "type": "text", 
          "analyzer": "ngramIndexAnalyzer"
        },
        "SPY": {
          "type": "text", 
          "analyzer": "pinyiSimpleIndexAnalyzer"
        },
        "FPY": {
          "type": "text", 
          "analyzer": "pinyiFullIndexAnalyzer"
        }
      }
    },
    "serviceFinanceEntType": {
      "type": "text",
      "analyzer": "ik_max_word",
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 256
        }
      }
    },
    "serviceSupport": {
      "type": "text",
      "analyzer": "ik_max_word",
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 256
        }
      }
    },
    "serviceEntRat": {
      "type": "text",
      "analyzer": "ik_max_word",
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 256
        }
      }
    }
  }
}

java 调用时

QueryBuilder normSearchBuilder=QueryBuilders.matchQuery("fields.ngram",words).analyzer("ngramSearchAnalyzer")
发布了56 篇原创文章 · 获赞 86 · 访问量 18万+

猜你喜欢

转载自blog.csdn.net/qq_32331997/article/details/86642101