【发布时间】:2019-07-12 20:36:31
【问题描述】:
下面是单行的kibana JSON,
{
"_index": "questionanswers",
"_type": "doc",
"_id": "3",
"_version": 1,
"_score": 0,
"_source": {
"question": {
"id": 3,
"text": "Your first salary",
"answer_type": "FL",
"question_type": "BQ"
},
"candidate": {
"id": 13
},
"job": {
"id": 6
},
"id": 3,
"status": "AN",
"answered_on": "2019-07-12T09:26:01+00:00",
"answer": "12222222"
},
"fields": {
"answered_on": [
"2019-07-12T09:26:01.000Z"
]
}
}
我有一个类似的 sql 查询,
Select * from questionanswers where question.id = 3 and answer between 1250 and 1253666
我已将其转换为 elasticsearch 查询,如下所示,
{
"size": 1000,
"query": {
"bool": {
"must": [
{
"term": {
"question.id":3
}
},
{
"range": {
"answer": {
"from": 1250,
"to": 1253666999,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
}
这里 answer 被声明为 String ,但我持有 Date、Float 和 String 值。
"question": {
"id": 3,
"text": "Your first salary",
"answer_type": "FL",
"question_type": "BQ"
},
这里answer_type 告诉它期望的答案类型。
当我尝试运行此查询时,我没有得到想要的结果。我对这次打击得到了空洞的回应。 但实际上,有一行满足这个查询。 我的 elasticsearch 查询应该如何过滤,以便我可以使用
question.id = 3 , question.answer_type = "FL" and answer between 1250 and 1253666```
【问题讨论】:
标签: python elasticsearch kibana