• termquery与matchquery的区别


    PUT test/_doc/1
    {
      "content":"Hello World"
    }
    GET test/_mapping
    
    {
      "test" : {
        "mappings" : {
          "properties" : {
            "content" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        }
      }
    }
    GET test/_analyze
    { 
      "explain": true, 
      "analyzer": "standard",
      "text": "Hello World"
    }
    
    POST test/_search
    {
      "profile": "true",
      "query": {
        "match": {
          "content": "Hello World" 
        }
      }
    }
    
    POST test/_search
    {
      "profile": "true",
      "query": {
        "match": {
          "content": "hello world"
        }
      }
    }
    #查的到数据,因为content.keyword在存数据的时候不分词,不做任何处理.存的就是Hello World
    POST test/_search
    {
      "profile": "true",
      "query": {
        "match": {
          "content.keyword": "Hello World"
        }
      }
    }
    #查不到数据,因为content.keyword在存数据的时候不分词,不做任何处理.存的就是Hello World,而你用小写的hello world去查询,所以查不到数据
    POST test/_search
    {
      "profile": "true",
      "query": {
        "match": {
          "content.keyword": "hello world"
        }
      }
    }
    #查不到,termquery :content:Hello World,你存的数据content是hello
    POST test/_search
    {
      "profile": "true",
      "query": {
        "term": {
          "content": "Hello World"
        }
      }
    }
    #termquery.查不到content作为整体去查
    POST test/_search
    {
      "profile": "true",
      "query": {
        "term": {
          "content": "hello world"
        }
      }
    }
    #查的到,content存的数据是Hello World,所以查得到
    POST test/_search
    {
      "profile": "true",
      "query": {
        "term": {
          "content.keyword": "Hello World"
        }
      }
    }
  • 相关阅读:
    TCP和UDP知识总结
    使用 DataX 增量同步数据(转)
    python对象类型
    Asp.net mvc使用SignaIR
    数据库分库分表思路 [转]
    Linux基本操作 [转]
    RabbitMQ入门教程 [转]
    设计模式
    设计模式六大原则
    Javascript实现数组去重 [转]
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/14182520.html
Copyright © 2020-2023  润新知