[英]Elasticsearch Facets: Search on _index returned no results
I want to search data on ES in this order by index-> by index_type-> text search data. 我想通过index-> by index_type->文本搜索数据以此顺序在ES上搜索数据。
When I'am using the below query on "_index" I expected to get list of index_types under that particular _index and also the related data but it returned nothing. 当我在“ _index”上使用以下查询时,我希望获得该特定_index下的index_types列表以及相关数据,但未返回任何内容。 On the other hand when I searched by _type I got the data pertaining to the index_type. 另一方面,当我通过_type搜索时,我得到了与index_type有关的数据。 Where have I gone wrong? 我哪里出问题了?
curl -XGET 'http://localhost:9200/_all/_search?pretty' -d '{
"facets": {
"terms": {
"terms": {
"field": "_index",
"size": 10,
"order": "count",
"exclude": []
},
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "*"
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"_index": [
"<index_name>"
]
}
}
]
}
}
}
}
}
}
}
},
"size": 0
}'
Note: I faced this problem first on Kibana, where I used the filter "_index":"name_of_index"; 注意:我首先在Kibana上遇到了这个问题,在这里我使用了过滤器“ _index”:“ name_of_index”; it returned no results but "_type":"name_of_index_type" returned the expected result. 它没有返回任何结果,但是“ _type”:“ name_of_index_type”返回了预期的结果。 I found Kibana uses the above query behind the scenes to get the results of the filter I tried. 我发现Kibana在幕后使用上面的查询来获取我尝试过的过滤器的结果。
this is an example of query with pre filter ( "query" : "*" ) and then a must&mustnot query. 这是一个带有预过滤器的查询示例(“ query”:“ *”),然后是必须查询。 then the resutlt is used to make the aggregations : 然后使用resutlt进行聚合:
curl -XGET 'http://localhost:9200/YOUR_INDEX_NAME/_search?size=10' -d '{
"query" : {
"filtered" : {
"query" : {
"query_string" : {
"query" : "*"
}
},
"filter" : {
"bool" : {
"must" : [
{ "term" : { "E_RECORDEDBY" : "malençon, g."} },
{ "term" : { "T_SCIENTIFICNAME" : "peniophora incarnata" } }
],
"must_not" : [
{"term" : { "L_CONTINENT" : "africa" } },
{"term" : { "L_CONTINENT" : "europe" } }
]
}
}
}
},
"aggs" : {
"L_CONTINENT" : {
"terms" : {
"field" : "L_CONTINENT",
"size" : 20
}
}
},
"sort" : "_score"
}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.