如何编写弹性搜索查询以获取包含日期和计数的 50 个问题的列表
How to write a elastic search query to get the list of 50 questions with the date and the count
我在编写弹性搜索查询时需要使用以下 2 个 MUST 条件
必须 - ("source.keyword": "SONAX1")
必须 - ("answer.keyword": "未处理")
必填字段(问题、时间戳和聚合计数)& SIZE = 需要 50 条记录
我的时间戳是纪元格式,显示记录时需要以日期格式显示。
下面是试过的查询
{
"query":{ "bool": { "must": { "term": { "answer.keyword": "UNHANDLED" } }, "must": { "term": { " source.keyword": "sonax" } } } }, "aggs": { "MyBuckets": { "terms": { "field": "question.keyword","timestamp", "sort": { "_timestamp": "desc" "_source": { "includes": [ "source":"question.keyword","timestamp",
},
“尺寸”:“50”
} } } }
错误如下:
- 重复键必须语法错误
请检查:缺少一些 synatx
不正确json,必将重名。
请尝试:
{
"query":{
"bool":{
"must":[
{
"term":{
"answer.keyword":"UNHANDLED"
}
},
{
"term":{
"source.keyword":"sonax"
}
}
]
}
}
}
我在编写弹性搜索查询时需要使用以下 2 个 MUST 条件
必须 - ("source.keyword": "SONAX1")
必须 - ("answer.keyword": "未处理")
必填字段(问题、时间戳和聚合计数)& SIZE = 需要 50 条记录
我的时间戳是纪元格式,显示记录时需要以日期格式显示。
下面是试过的查询
{
"query":{ "bool": { "must": { "term": { "answer.keyword": "UNHANDLED" } }, "must": { "term": { " source.keyword": "sonax" } } } }, "aggs": { "MyBuckets": { "terms": { "field": "question.keyword","timestamp", "sort": { "_timestamp": "desc" "_source": { "includes": [ "source":"question.keyword","timestamp",
}, “尺寸”:“50” } } } }
错误如下:
- 重复键必须语法错误
请检查:缺少一些 synatx
不正确json,必将重名。 请尝试:
{
"query":{
"bool":{
"must":[
{
"term":{
"answer.keyword":"UNHANDLED"
}
},
{
"term":{
"source.keyword":"sonax"
}
}
]
}
}
}