我遇到弹性搜索问题,查询DSL' mustNot'
这是我的代码:
$string = new Query\QueryString();
$string->setQuery('*');
$term = new Term();
$term->setTerm($this->attribute,$this->value);
$mustNot = new Bool();
$mustNot->addMustNot($term);
$query = new Query();
$query->setQuery($string);
$query->setPostFilter($mustNot);
return $query;
我的结果:
SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[qqgJrK0OTGCfXPX5Yd7X3A][data_from_mapper_3][2]: SearchParseException[[data_from_mapper_3][2]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"*"}},"post_filter":{"bool":{"must_not":[{"term":{"_score":1}}]}}}]]]; nested: SearchParseException[[data_from_mapper_3][2]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No parser for element [post_filter]]]; }{[qqgJrK0OTGCfXPX5Yd7X3A][data_from_mapper_3][1]: SearchParseException[[data_from_mapper_3][1]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"*"}},"post_filter":{"bool":{"must_not":[{"term":{"_score":1}}]}}}]]]; nested: SearchParseException[[data_from_mapper_3][1]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No parser for element [post_filter]]]; }{[qqgJrK0OTGCfXPX5Yd7X3A][data_from_mapper_3][4]: SearchParseException[[data_from_mapper_3][4]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"*"}},"post_filter":{"bool":{"must_not":[{"term":{"_score":1}}]}}}]]]; nested: SearchParseException[[data_from_mapper_3][4]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No parser for element [post_filter]]]; }{[qqgJrK0OTGCfXPX5Yd7X3A][data_from_mapper_3][3]: SearchParseException[[data_from_mapper_3][3]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"*"}},"post_filter":{"bool":{"must_not":[{"term":{"_score":1}}]}}}]]]; nested: SearchParseException[[data_from_mapper_3][3]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No parser for element [post_filter]]]; }{[qqgJrK0OTGCfXPX5Yd7X3A][data_from_mapper_3][0]: SearchParseException[[data_from_mapper_3][0]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"*"}},"post_filter":{"bool":{"must_not":[{"term":{"_score":1}}]}}}]]]; nested: SearchParseException[[data_from_mapper_3][0]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [No parser for element [post_filter]]]; }]