我的目的是获取与指定日期范围和uuid (唯一用户ID)匹配的记录。查询似乎失败了:

如果我使用用户名尝试相同的查询,那么它就能工作。

我怀疑搜索字符串中的:字符,并尝试使用\对其进行转义,但仍然无法工作。
有什么问题吗?
这些映射是:
{
"top_flows": {
"mappings": {
"top flows": {
"properties": {
"name": {
"type": "string"
},
"postDate": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"uuid": {
"type": "string"
}
}
}
}
}
}要添加到elasticsearch中的JSON文档是:
doc = {
'postDate': timestamp_str,
'uuid': uuid,
'name': 'sam'
}
timestamp = time.time()
timestamp_str = datetime.fromtimestamp(timestamp).strftime('%Y-%m-%dT%H:%M:%S')
res = self.__eshandle.index(index="top_flows", doc_type='top flows', id=int(timestamp), body=doc)发布于 2016-04-21 10:52:12
下面终于有结果了!
GET /top_flows/_search
{
"query" : {
"range" : {
"postDate" : {
"from" : "now-5m",
"to" : "now"
}
}
},
"filter": {
"query_string": {
"query": "FF\\:FF\\:FF\\:FF\\:FF\\:FF\\:FF\\:FF\\:FF\\:FF\\:FF\\:11\\:8F\\:FF\\:FF\\:FF",
"fields": ["uuid"]
}
}
}还不确定为什么以前的方法失败了:
https://stackoverflow.com/questions/36743367
复制相似问题