zoukankan      html  css  js  c++  java
  • 基于词项和基于全文的搜索


    DELETE products
    
    PUT products
    {
      "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0
      }
    }
    
    
    POST /products/_bulk
    { "index": { "_id": 1 }}
    { "productID" : "XHDK-A-1293-#fJ3","desc":"iPhone" }
    { "index": { "_id": 2 }}
    { "productID" : "KDKE-B-9947-#kL5","desc":"iPad" }
    { "index": { "_id": 3 }}
    { "productID" : "JODL-X-1937-#pV7","desc":"MBP" }
    
    GET /products
    
    POST /products/_search
    {
      "query": {
        "term": {
          "desc": {
            //"value": "iPhone" # 查询不出来,因为经过分词后是小写的了
            "value":"iphone" # 可以查询出来
          }
        }
      }
    }
    
    POST /products/_search
    {
      "query": {
        "term": {
          "desc.keyword": {
            //"value": "iPhone" # 可以查询出来,keyword表示精确查找
            //"value":"iphone" # 查询不出来
          }
        }
      }
    }
    
    
    POST /products/_search 
    {
      "query": {
        "term": {
          "productID": {
            "value": "XHDK-A-1293-#fJ3" # 查询不出来
          }
        }
      }
    }
    
    POST /products/_search
    {
      //"explain": true, # 显示详细的查询经过
      "query": {
        "term": {
          "productID.keyword": {
            "value": "XHDK-A-1293-#fJ3" # 可以查询出来
          }
        }
      }
    }
    


    POST /products/_search
    {
      "explain": true,
      "query": {
        "constant_score": {
          "filter": {
            "term": {
              "productID.keyword": "XHDK-A-1293-#fJ3"
            }
          }
    
        }
      }
    }
    





    PUT groups
    {
      "mappings": {
        "properties": {
          "names": {
            "type": "text",
            "position_increment_gap": 0
          }
        }
      }
    }
    
    GET groups/_mapping
    
    POST groups/_doc
    {
      "names": [
        "John Water",
        "Water Smith"
      ]
    }
    
    
    # 可以查询出来数据
    POST groups/_search
    {
      "query": {
        "match_phrase": {
          "names": {
            "query": "Water Water",
            "slop": 100
          }
        }
      }
    }
    
    # 可以查询出来数据
    POST groups/_search
    {
      "query": {
        "match_phrase": {
          "names": "Water Smith"
        }
      }
    }
    
  • 相关阅读:
    比较两个NSDate
    关于修改UIWebView的UserAgent
    iOS9适配 之 关于info.plist 第三方登录 添加URL Schemes白名单
    iOS系统自带分享功能
    swift中的协议
    iOS性能优化:Instruments使用实战
    iOS利用HealthKit框架从健康app中获取步数信息
    iOS设备型号
    iOS消息推送机制
    Swift进阶
  • 原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/14518672.html
Copyright © 2011-2022 走看看