我正在尝试运行显示所有“索引”的查询,但显示count = 0
的某些位置。我不希望出现其中count = 0.
我尝试使用must_not
但未解决。我该怎么做?
我的搜索
curl -XGET 'http://127.0.0.1:9200/oknok/base_gerenciada/_search' -d '{
"from": 0,
"size": 0,
"query":{
"bool":{
"must":[{
"term":{
"last":true
}
}]
}
},
"facets": {
"filters": {
"terms": {
"field": "spec_veiculo.raw",
"all_terms": true,"size" : 999999,
"order": "term"
}
}
}}'
我的结果(例子)
{"took":11,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},
"hits":{"total":8375,"max_score":0.0,"hits":[]},
"facets":{"filters":
{"_type":
"terms",
"missing":0,
"total":8375,
"other":0,
"terms"[
{"term":"Abril - Arquitetura & Construção","count":67},
{"term":"Abril - Aventuras na História","count":67},
{"term":"Abril - Bebe.com.br","count":67},
{"term":"Abril - Boa Forma","count":67},
{"term":"Abril - Bons Fluidos","count":67},
{"term":"Abril - Capricho","count":67},
{"term":"Abril - Casa Claudia","count":67},
{"term":"Abril - Casa.com.br","count":67},
{"term":"Abril - Claudia","count":67},
{"term":"Abril - Contigo!","count":67},
{"term":"Abril - Elle","count":67},
{"term":"Abril - Estilo","count":67},
{"term":"Abril - Exame","count":67},
{"term":"Abril - Exame PME","count":67},
{"term":"Abril - Gestão Escolar","count":67},
{"term":"Abril - Guia Quatro Rodas","count":67},
{"term":"Abril - Guia do Estudante","count":67},
{"term":"Abril - Hotel Pro","count":67},
{"term":"Abril - Info","count":67},
{"term":"Abril - Manequim","count":67},
{"term":"Abril - MdeMulher","count":67}
当我使用must_not
daniela.morais@tusk:~$ curl -XGET 'http://127.0.0.1:9200/oknok/base_gerenciada/_search' -d '{"from": 0, "size": 0, "query":{"bool":{"must":[{"term":{"last":true}}]}, "must_not":[{"count":0}]}, "facets": {"filters": {"terms": {"field": "spec_veiculo.raw", "all_terms": true,"size" : 999999, "order": "term"}}}}'
{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[1MOjVLWpTwmINmoKy8Zh3Q][oknok][0]: SearchParseException[[oknok][0]: query[+last:T],from[0],size[0]: Parse Failure [Failed to parse source [{\"from\": 0, \"size\": 0, \"query\":{\"bool\":{\"must\":[{\"term\":{\"last\":true}}]}, \"must_not\":[{\"count\":0}]}, \"facets\": {\"filters\": {\"terms\": {\"field\": \"spec_veiculo.raw\", \"all_terms\": true,\"size\" : 999999, \"order\": \"term\"}}}}]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"must_not\"]; }{[1MOjVLWpTwmINmoKy8Zh3Q][oknok][1]: SearchParseException[[oknok][1]: query[+last:T],from[0],size[0]: Parse Failure [Failed to parse source [{\"from\": 0, \"size\": 0, \"query\":{\"bool\":{\"must\":[{\"term\":{\"last\":true}}]}, \"must_not\":[{\"count\":0}]}, \"facets\": {\"filters\": {\"terms\": {\"field\": \"spec_veiculo.raw\", \"all_terms\": true,\"size\" : 999999, \"order\": \"term\"}}}}]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"must_not\"]; }{[1MOjVLWpTwmINmoKy8Zh3Q][oknok][2]: SearchParseException[[oknok][2]: query[+last:T],from[0],size[0]: Parse Failure [Failed to parse source [{\"from\": 0, \"size\": 0, \"query\":{\"bool\":{\"must\":[{\"term\":{\"last\":true}}]}, \"must_not\":[{\"count\":0}]}, \"facets\": {\"filters\": {\"terms\": {\"field\": \"spec_veiculo.raw\", \"all_terms\": true,\"size\" : 999999, \"order\": \"term\"}}}}]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"must_not\"]; }{[1MOjVLWpTwmINmoKy8Zh3Q][oknok][3]: SearchParseException[[oknok][3]: query[+last:T],from[0],size[0]: Parse Failure [Failed to parse source [{\"from\": 0, \"size\": 0, \"query\":{\"bool\":{\"must\":[{\"term\":{\"last\":true}}]}, \"must_not\":[{\"count\":0}]}, \"facets\": {\"filters\": {\"terms\": {\"field\": \"spec_veiculo.raw\", \"all_terms\": true,\"size\" : 999999, \"order\": \"term\"}}}}]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"must_not\"]; }{[1MOjVLWpTwmINmoKy8Zh3Q][oknok][4]: SearchParseException[[oknok][4]: query[+last:T],from[0],size[0]: Parse Failure [Failed to parse source [{\"from\": 0, \"size\": 0, \"query\":{\"bool\":{\"must\":[{\"term\":{\"last\":true}}]}, \"must_not\":[{\"count\":0}]}, \"facets\": {\"filters\": {\"terms\": {\"field\": \"spec_veiculo.raw\", \"all_terms\": true,\"size\" : 999999, \"order\": \"term\"}}}}]]]; nested: ElasticsearchParseException[Expected field name but got START_ARRAY \"must_not\"]; }]","status":400}
我无法使用Not Filter
{
"from": 0,
"size": 0,
"query": {
"bool": {
"must": [
{
"term": {
"last": true
}
}
]
}
},
"facets": {
"filters": {
"terms": {
"field": "spec_veiculo.raw",
"all_terms": true,
"size": 999999,
"order": "term"
},
"not": {
"filter" : {
"terms": {
"count": 0
}
}
}
}
}
}
答案 0 :(得分:0)
尝试以下方法。你的语法错了。
{
"from": 0,
"size": 0,
"query": {
"bool": {
"must": [
{
"term": {
"last": true
}
}
],
"must_not": [
{
"term": {
"count": 0
}
}
]
}
},
"facets": {
"filters": {
"terms": {
"field": "spec_veiculo.raw",
"all_terms": true,
"size": 999999,
"order": "term"
}
}
}
}
答案 1 :(得分:0)
根据reference, all_terms 返回所有项目,即使count为0 ,也只能更改为 all_terms:false < / p>
{
"from": 0,
"size": 0,
"query": {
"bool": {
"must": [
{
"term": {
"last": true
}
}
]
}
},
"facets": {
"filters": {
"terms": {
"field": "spec_veiculo.raw",
"all_terms": false,
"size": 999999,
"order": "term"
}
}
}
}