美文网首页
工作中的Elasticsearch-kibana访问

工作中的Elasticsearch-kibana访问

作者: 先生_吕 | 来源:发表于2018-09-18 17:50 被阅读28次
//1、创建nlpindex索引
PUT /nlpindex
{
  "mappings": {
    "nlpinfo": {
      "properties": {
          "content": {
            "type": "keyword",
            "ignore_above": 20000
          },
          "ctime": {
            "type": "long"
          },
          "docId": {
            "type": "keyword"
          },
          "title": {
            "type": "keyword"
          },
          "username": {
            "type": "keyword"
          }
        }
    }
  },
  "settings": {
    "index": {
      "routing": {
        "allocation": {
          "total_shards_per_node": "16"
        }
      },
      "number_of_shards": "16",
      "translog": {
        "durability": "async"
      },
      "number_of_replicas": "1"
    }
  }
}

//2、根据对应字段查询
POST nlpindex/nlpinfo/_search
{
  "query" : {
    "term" : {
      "docId" : "9108264"
    }
  }
}

//3、id 查询
GET nlpindex_/nlpinfo/395995

//4、模糊匹配
POST nlpindex/nlpinfo/_search?
{
  "query" : {
    "wildcard" : {
      "content" : "*测试*"
    }
  },
  "size":  10000
}

//5、多字段
POST nlpindex/nlpinfo/_search
{
  "query": {
    "multi_match" : {
      "query":    "啊啊啊啊啊啊啊啊啊啊", 
      "fields": [ "content", "title" ] 
    }
  }
}

//6、字段全文匹配
POST nlpindex1/nlpinfo/_search
{
  "query" : {
    "term" : {
      "title" : "视频评论111"
    }
  }
}

//7、组合条件
GET nlpindex/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "ctime": {
              "gte": 1523086282000,
              "lte": 1523089114000
            }
          }
        },
        {
          "wildcard": {
            "content": "*歪果仁*"
          }
        }
      ]
    }
  }
}

//8、时间段
GET nlpindex/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "ctime": {
              "gt": 1536139076000
            }
          }
        }
      ]
    }
  }
}

//9、时间段最大值
GET nlpindex/_search
{
   "size": 0,
   "aggs": {
     "maxCtime": {
       "max": {
         "field": "ctime"
       }
     }
   }
 }

//10、删除
DELETE nlpindex_newly/nlpinfo/101059504

//11、添加
PUT /nlpindex_newly/nlpinfo/131960469
{
  "docId": "131960469",
  "username": "有梦9",
  "title": "优雅时尚9",
  "content": "999999999999999",
  "ctime": 1546757889000
}

//12、区间查
POST nlpindex1/nlpinfo/_search?
{
  "size" : 10000,
  "query" : {
    "bool" : {
      "must" : {
        "range" : {
          "ctime" : {
            "from" : null,
            "to" : 1546757887000,
            "include_lower" : true,
            "include_upper" : true
          }
        }
      }
    }
  }
}

//13、其他查询
get _cat/health?v
GET _cat/indices?v
GET /nlpindex_

上张图


kibana.png

相关文章

网友评论

      本文标题:工作中的Elasticsearch-kibana访问

      本文链接:https://www.haomeiwen.com/subject/rifmnftx.html