工作中的Elasticsearch-kibana访问

/_search:所有索引,所有type下的所有数据都搜索出来
/index1/_search:指定一个index,搜索其下所有type的数据
/index1,index2/_search:同时搜索两个index下的数据
/1,2/_search:按照通配符去匹配多个索引
/index1/type1/_search:搜索一个index下指定的type的数据
/index1/type1,type2/_search:可以搜索一个index下多个type的数据
/index1,index2/type1,type2/_search:搜索多个index下的多个type的数据
/_all/type1,type2/_search:_all,可以代表搜索所有index下的指定type的数据

//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

POST risk-818-nginx-log/doc/_delete_by_query
{
  "query": {"match_all": {}}
}

//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访问)