elasticsearch 中term查询

PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "full_text": {
          "type":  "string"
        },
        "exact_value": {
          "type":  "string",
          "index": "not_analyzed"
        }
      }
    }
  }
}

PUT my_index/my_type/1
{
  "full_text":   "Quick Foxes!",
  "exact_value": "Quick Foxes!"  
}



其中的full_text是被分析过的,所以full_text的索引中存的就是[quick, foxes],而extra_value中存的是[Quick Foxes!]。








GET my_index/my_type/_search
{
  "query": {
    "term": {
      "exact_value": "Quick Foxes!"
    }
  }
}


此时可以查到数据,请求的出数据,因为完全匹配



GET my_index/my_type/_search
{
  "query": {
    "term": {
      "full_text": "Quick Foxes!"
    }
  }
}


此时,就找不到数据,请求不出数据的,因为full_text分词后的结果中没有[Quick Foxes!]这个分词。

 

posted @ 2021-10-14 17:27  小啊菜鸡  阅读(216)  评论(0编辑  收藏  举报