【发布时间】:2018-08-08 16:46:13
【问题描述】:
我正在学习如何使用来自 pushshift.io 的 2006 年 reddit cmets 数据集来使用 elasticsearch。
created_utc 是包含创建评论时间的字段。
我正在尝试获取特定时间范围内的所有帖子。我google了一下,发现我需要使用“范围”关键字。
这是我现在的查询:
{
"query": {
"match" : {
"range": {
"created_utc": {
"gte": "1/1/2006",
"lte": "31/1/2006",
"format": "dd/MM/yyyy"
}
}
}
}
}
然后我尝试使用 bool 查询,这样我就可以将时间范围与edited must not = False 匹配(edited 是告诉我帖子是否已被编辑的布尔字段):
{
"query": {
"bool" : {
"must" : {
"range" : {
"created_utc": {
"gte" : "01/12/2006", "lte": "31/12/2006", "format": "dd/MM/yyyy"
}
}
},
"must_not": {
"edited": False
}
}
}
}
但是,这给了我另一个我无法弄清楚的错误:
[已编辑] 查询格式错误,查询名称后没有 start_object
如果有人能帮我解决这个问题,我将不胜感激,谢谢!
如果有帮助,这是我的评论映射:
{
"comment":{
"properties":{
"author":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"body":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"controversiality":{
"type":"long"
},
"created_utc":{
"type":"date"
},
"edited":{
"type":"boolean"
},
"gilded":{
"type":"long"
},
"id":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"link_id":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"parent_id":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"score":{
"type":"long"
},
"subreddit":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
}
}
【问题讨论】:
标签: elasticsearch