4
我使用elasticsearch搜索引擎,当我运行下面的代码,返回的结果不符合标准的范围内(我得到低于期望的极限公布日期的项目):范围过滤器不工作
#!/bin/bash
curl -X GET 'http://localhost:9200/newsidx/news/_search?pretty' -d '{
"fields": [
"art_text",
"title",
"published",
"category"
],
"query": {
"bool": {
"should": [
{
"fuzzy": {"art_text": {"boost": 89, "value": "google" }}
},
{
"fuzzy": {"art_text": {"boost": 75, "value": "twitter" }}
}
],
"minimum_number_should_match": 1
}
},
"filter" : {
"range" : {
"published" : {
"from" : "2013-04-12 00:00:00"
}
}
}
}
'
我也尝试把范围子句放在一个必须的,在布尔查询中,但结果是一样的。
编辑:我使用elasticsearch通过河流插件在mongodb中搜索。这是我用ES搜索mongodb db的脚本:
#!/bin/bash
curl -X PUT localhost:9200/_river/mongodb/_meta -d '{
"type":"mongodb",
"mongodb": {
"db": "newsful",
"collection": "news"
},
"index": {
"name": "newsidx",
"type": "news"
}
}'
除此之外,我没有创建其他索引。
编辑2:
视图到ES映射:
http://localhost:9200/newsidx/news/_mapping
published: {
type: "string"
}
是您的'发布'字段索引为日期?你可以发布你目前的地图吗? – javanna
我编辑帖子为了回答你的问题。 – Rod0n