English 中文(简体)
无文档的 ElasticSearch 面板结果
原标题:ElasticSearch facet results without document

我试图为我索引的一些事件获取直方图, 但我只想要在回应中显示表面结果, 而不是搜索+表面结果 。

这是正在运行的查询 I 的一个例子 :

curl -XGET  http://localhost:9200/main/events/_search?pretty=true  -d  
{
   "facets" : {
    "histo1" : {
       "query" : {
            "query_string" : {"query":"*:*"}
        },
         "date_histogram" : {
            "field" : "time",
            "interval" : "minute"
        }
    }
  }
}
 

因此,在结果中,我想 仅仅拥有

"facets" : {
"histo1" : {
  "_type" : "date_histogram",
  "entries" : [ {
    "time" : 1337700000,
    "count" : 76
  } ]
}

部分,不包含与查询匹配的所有文档。

有可能吗?

非常感谢。

最佳回答

您可以使用"http://www.elesticsearch.org/guide/reference/api/search/search-type/" rel="noreferr" >count search_type:

curl -XGET  http://localhost:9200/main/events/_search?search_type=count&pretty=true  -d  
{
  "facets" : {
    "histo1" : {
       "query" : {
            "query_string" : {"query":"*:*"}
        },
         "date_histogram" : {
            "field" : "time",
            "interval" : "minute"
        }
    }
  }
}
  

也可以将 “ size”: 0 设置为您的查询,但效率较低 :

curl -XGET  http://localhost:9200/main/events/_search?pretty=true  -d  
{
  "facets" : {
    "histo1" : {
       "query" : {
            "query_string" : {"query":"*:*"}
        },
         "date_histogram" : {
            "field" : "time",
            "interval" : "minute"
        }
    }
  },
  "size":0
}
 
问题回答

暂无回答




相关问题
Roll over index with elastic search and serilog

We are using es 6.7 and serilog 7.1 in our dotnet core application. In our logger implementation vi are using the following index "app-{0:yyyy.MM}-1" for our ElasticsearchSinkOptions. This ...

Change the date format in kibana

I am working for my internship on the implementation of the ElasticSearch family (ElasticSearch+ Kibana+ logstash). Here is my question: I have a field "@ timestamp" with the following format: 2014-05-...

热门标签