如何在字段具有特定值的情况下执行排除结果的搜索?
我有一个Reddit评论数据库,我想找比特币提及,但排除比特币subreddit.
curl -s -XGET 'http://localhost:9200/_search?pretty=true&size=100' -d ' { "filtered": { "query" : { "match": { "body": "bitcoin" } }, "filter": { "not": { "term": { "subreddit": "bitcoin" } } } } }'
这里的错误很长.https://gist.github.com/kylelk/feca416156712eebad3e
这是一个愚蠢的错误,
您必须在查询中包含筛选查询.这是修改
POST _search { "query": { "filtered": { "query": { "match": { "body": "bitcoin" } }, "filter": { "not": { "term": { "subreddit": "bitcoin" } } } } } }
希望这可以帮助!!