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