0

我的查询是这个。我的目的只是如果国家为空,我想排除该数据。

q='{
    "sort": [{
        "creation_time": {
            "order": "desc"
        }
    }],
    "fields": ["id", "link_extracted","country"],
    "from": 0,
    "size": 50,
        "query": {
        "filtered": {
            "query": {
                "match_all": {}
            },
                "filter": {

                    "and": {
                    "filters": [
                    {
                        "must_not": {
                        "missing": {
                            "field": "country",
                                "existence": true,
                                "null_value": true
                        }
                    }
                    },



                    {
                        "range": {
                            "creation_time": {
                                "from": "2013-07-24",
                                "to": "2013-07-25",
                                "include_lower": true,
                                "include_upper": true
                            }
                        }
                    }, {
                        "term": {
                            "stream_type": "facebook"
                        }
                    },


                    {
                        "or": [{
                            "query": {
                                "query_string": {
                                    "fields": ["post_message", "description", "post_name", "caption", "content", "tweet_text", "title", "positive_keyword"],
                                    "default_operator": "AND",
                                    "query": "obama"
                                }
                            }
                        }, {
                            "query": {
                                "query_string": {
                                    "fields": ["post_message", "description", "post_name", "caption", "content", "tweet_text", "title", "positive_keyword"],
                                    "default_operator": "AND",
                                    "query": "goibibo"
                                }
                            }
                        }]
                    }],
                    "_cache": true
                }
            }
        }
    }
}'

它返回错误。请有人帮助我

error: SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[dE5tGteLRz61iFpbB3KBcA][monitoring2][1]: SearchParseException[[monitoring2][1]: from[0],size[50],sort[<custom:"creation_time": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@1faa54ab>!]: Parse Failure [Failed to parse source [{"sort":[{"creation_time":{"order":"desc"}}],"fields":["id","link_extracted","country"],"from":0,"size":50,"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":{"filters":[{"must_not":{"missing":{"field":"country","existence":true,"null_value":true}}},{"range":{"creation_time":{"from":"2013-07-24","to":"2013-07-25","include_lower":true,"include_upper":true}}},{"term":{"stream_type":"facebook"}},{"or":[{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"obama"}}},{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"goibibo"}}}]}],"_cache":true}}}}}]]]; nested: QueryParsingException[[monitoring2] No filter registered for [must_not]]; }{[dE5tGteLRz61iFpbB3KBcA][monitoring2][4]: SearchParseException[[monitoring2][4]: from[0],size[50],sort[<custom:"creation_time": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@5756e049>!]: Parse Failure [Failed to parse source [{"sort":[{"creation_time":{"order":"desc"}}],"fields":["id","link_extracted","country"],"from":0,"size":50,"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":{"filters":[{"must_not":{"missing":{"field":"country","existence":true,"null_value":true}}},{"range":{"creation_time":{"from":"2013-07-24","to":"2013-07-25","include_lower":true,"include_upper":true}}},{"term":{"stream_type":"facebook"}},{"or":[{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"obama"}}},{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"goibibo"}}}]}],"_cache":true}}}}}]]]; nested: QueryParsingException[[monitoring2] No filter registered for [must_not]]; }{[dE5tGteLRz61iFpbB3KBcA][monitoring2][3]: SearchParseException[[monitoring2][3]: from[0],size[50],sort[<custom:"creation_time": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@66ed8bb>!]: Parse Failure [Failed to parse source [{"sort":[{"creation_time":{"order":"desc"}}],"fields":["id","link_extracted","country"],"from":0,"size":50,"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":{"filters":[{"must_not":{"missing":{"field":"country","existence":true,"null_value":true}}},{"range":{"creation_time":{"from":"2013-07-24","to":"2013-07-25","include_lower":true,"include_upper":true}}},{"term":{"stream_type":"facebook"}},{"or":[{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"obama"}}},{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"goibibo"}}}]}],"_cache":true}}}}}]]]; nested: QueryParsingException[[monitoring2] No filter registered for [must_not]]; }{[dE5tGteLRz61iFpbB3KBcA][monitoring2][0]: SearchParseException[[monitoring2][0]: from[0],size[50],sort[<custom:"creation_time": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@1faa54ab>!]: Parse Failure [Failed to parse source [{"sort":[{"creation_time":{"order":"desc"}}],"fields":["id","link_extracted","country"],"from":0,"size":50,"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":{"filters":[{"must_not":{"missing":{"field":"country","existence":true,"null_value":true}}},{"range":{"creation_time":{"from":"2013-07-24","to":"2013-07-25","include_lower":true,"include_upper":true}}},{"term":{"stream_type":"facebook"}},{"or":[{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"obama"}}},{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"goibibo"}}}]}],"_cache":true}}}}}]]]; nested: QueryParsingException[[monitoring2] No filter registered for [must_not]]; }{[dE5tGteLRz61iFpbB3KBcA][monitoring2][2]: SearchParseException[[monitoring2][2]: from[0],size[50],sort[<custom:"creation_time": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@89f056b>!]: Parse Failure [Failed to parse source [{"sort":[{"creation_time":{"order":"desc"}}],"fields":["id","link_extracted","country"],"from":0,"size":50,"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":{"filters":[{"must_not":{"missing":{"field":"country","existence":true,"null_value":true}}},{"range":{"creation_time":{"from":"2013-07-24","to":"2013-07-25","include_lower":true,"include_upper":true}}},{"term":{"stream_type":"facebook"}},{"or":[{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"obama"}}},{"query":{"query_string":{"fields":["post_message","description","post_name","caption","content","tweet_text","title","positive_keyword"],"default_operator":"AND","query":"goibibo"}}}]}],"_cache":true}}}}}]]]; nested: QueryParsingException[[monitoring2] No filter registered for [must_not]]; }]
status: 500
}
4

1 回答 1

0

尝试这个。(must_not不是过滤器类型,我将其更改为not

{
    "sort": [
        {
            "creation_time": {
                "order": "desc"
            }
        }
    ],
    "fields": ["id", "link_extracted", "country"],
    "from": 0,
    "size": 50,
    "query": {
        "filtered": {
            "query": {
                "match_all": {}
            },
            "filter": {
                "and": {
                    "filters": [
                        {
                            "not": {
                                "missing": {
                                    "field": "country",
                                    "existence": true,
                                    "null_value": true
                                }
                            }
                        },
                        {
                            "range": {
                                "creation_time": {
                                    "from": "2013-07-24",
                                    "to": "2013-07-25",
                                    "include_lower": true,
                                    "include_upper": true
                                }
                            }
                        }, 
                        {
                            "term": {
                                "stream_type": "facebook"
                            }
                        },
                        {
                            "or": [
                                {
                                    "query": {
                                        "query_string": {
                                            "fields": ["post_message", "description", "post_name", "caption", "content", "tweet_text", "title", "positive_keyword"],
                                            "default_operator": "AND",
                                            "query": "obama"
                                        }
                                    }
                                },
                                {
                                    "query": {
                                        "query_string": {
                                            "fields": ["post_message", "description", "post_name", "caption", "content", "tweet_text", "title", "positive_keyword"],
                                            "default_operator": "AND",
                                            "query": "goibibo"
                                        }
                                    }
                                }
                            ]
                        }
                    ],
                    "_cache": true
                }
            }
        }
    }
}
于 2013-07-25T09:40:50.423 回答