我正在尝试获取我已编入索引的某些事件的直方图,但我只想在响应中使用'facet results'而不是search + facet结果.
这是我正在运行的查询的示例:
curl -XGET 'http://localhost:9200/main/events/_search?pretty=true' -d '
{
"facets" : {
"histo1" : {
"query" : {
"query_string" : {"query":"*:*"}
},
"date_histogram" : {
"field" : "time",
"interval" : "minute"
}
}
}
}
'
Run Code Online (Sandbox Code Playgroud)
所以在结果中我想要的只是
"facets" : {
"histo1" : {
"_type" : "date_histogram",
"entries" : [ {
"time" : 1337700000,
"count" : 76
} ]
}
Run Code Online (Sandbox Code Playgroud)
部分,没有与查询匹配的所有文档.
这可能吗?
非常感谢.
imo*_*tov 28
您可以使用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"
}
}
}
}
'
Run Code Online (Sandbox Code Playgroud)
或者,您可以设置"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
}
'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4038 次 |
| 最近记录: |