zoukankan      html  css  js  c++  java
  • ES 搜索一(term)

    POST /forum/article/_bulk
    {"index":{"_id":1}}
    { "articleID" : "XHDK-A-1293-#fJ3", "userID" : 1, "hidden": false, "postDate": "2017-01-01" }
    { "index": { "_id": 2 }}
    { "articleID" : "KDKE-B-9947-#kL5", "userID" : 1, "hidden": false, "postDate": "2017-01-02" }
    { "index": { "_id": 3 }}
    { "articleID" : "JODL-X-1937-#pV7", "userID" : 2, "hidden": false, "postDate": "2017-01-01" }
    { "index": { "_id": 4 }}
    { "articleID" : "QQPX-R-3956-#aD8", "userID" : 2, "hidden": true, "postDate": "2017-01-02" }
    
    
    GET /forum/_mapping/article
    
    
    GET /forum/article/_search
    {
      "query": {
        "constant_score": {
          "filter": {
            "term": {
              "userID": "2"
            }
          }
        }
      }
    }
    
    
    GET /forum/article/_search
    {
      "query": {
        "constant_score": {
          "filter": {
            "term": {
              "hidden": true
            }
          }
        }
      }
    }
    
    GET /forum/article/_search
    {
      "query": {
        "constant_score": {
          "filter": {
            "term": {
              "articleID.keyword": "QQPX-R-3956-#aD8"
            }
          } 
        }
      }
    }
     
    GET /forum/article/_mapping
     
    
    DELETE /forum
    
    PUT /forum
    {
      "mappings": {
        "article":{
          "properties": {
            "articleID":{
              "type": "keyword"
            }
          }
        }
      }
    }
    
    
    PUT /forum
    {
      "mappings": {
        "article":{
          "properties": {
            "articleID":{
              "type": "keyword"
            }
          }
        }
      }
    }
    
    POST /forum/article/_bulk
    { "index": { "_id": 1 }}
    { "articleID" : "XHDK-A-1293-#fJ3", "userID" : 1, "hidden": false, "postDate": "2017-01-01" }
    { "index": { "_id": 2 }}
    { "articleID" : "KDKE-B-9947-#kL5", "userID" : 1, "hidden": false, "postDate": "2017-01-02" }
    { "index": { "_id": 3 }}
    { "articleID" : "JODL-X-1937-#pV7", "userID" : 2, "hidden": false, "postDate": "2017-01-01" }
    { "index": { "_id": 4 }}
    { "articleID" : "QQPX-R-3956-#aD8", "userID" : 2, "hidden": true, "postDate": "2017-01-02" }
    
    
    GET /forum/article/_search
    {
      "query": {
        "constant_score": {
          "filter": {
            "term": {
              "articleID": "JODL-X-1937-#pV7"
            }
          }
      
        }
      }
    }

    term是搜字段完全匹配,在建立索引时,如果类型是text时,会被分词建立倒排索引,如果不想让字段倒排索引,可以设置其类型为keyword。

  • 相关阅读:
    java将string转化为int Yannis
    vm虚拟机启动报The VMware Authorization Service is not running错误 Yannis
    [org.hibernate.util.JDBCExceptionReporter] Cannot load JDBC driver class 'net. Yannis
    前台页面分页对总页数的判断 Yannis
    事务及其特性 Yannis
    iReport报表的简单函数及部分操作 Yannis
    spring aop与事务配置 Yannis
    大数据的验证和插入数据库 Yannis
    唔哇哈哈,拉霸机
    bindebug放到别的目录后不能看?编译器参数设置一下
  • 原文地址:https://www.cnblogs.com/javabeginer/p/13059817.html
Copyright © 2011-2022 走看看