基于某些字段在弹性搜索中搜索数据

时间:2017-07-06 09:04:10

标签: elasticsearch

我是EL新手,希望根据“type:”搜索此数据:“load”。

请帮忙

    {
   "took": 14,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1109,
      "max_score": 1,
      "hits": [
         {"_index": "4",
            "_type": "aa",
            "_id": "xx",
            "_score": 1,
            "_source": {
               "useRange": false,
               "Blueprint": 4,
               "standardDeviation": 0,
               "occurrences": 0,
               "type:": "load",
               }...
               {
               }

2 个答案:

答案 0 :(得分:2)

Elasticsearch文档将帮助您: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html

修改

查询为curl -XGET 'localhost:9200/sample/_search?q=type:load&pretty'

和输出

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.30685282,
    "hits" : [ {
      "_index" : "sample",
      "_type" : "data",
      "_id" : "1",
      "_score" : 0.30685282,
      "_source" : {
        "useRange" : false,
        "Blueprint" : 4,
        "standardDeviation" : 0,
        "occurrences" : 0,
        "type" : "load"
      }
    } ]
  }
}

答案 1 :(得分:0)

问题是字段名称'type'我们将名称更改为typemetrics,以下查询正在运行 我的东西类型可能充当关键字

" GET /4/_search
{
  "query": {
    "term" : { "typemetrics" : "load"} 
  }
} "