I have the following aggregation which show all the count by values for a
particular field values.
http://localhost:8200/index1/collection1/_search?search_type=count
{
"aggs" : {
"effects" : {
"terms" : {
"field" : "type"
}
}
}
}
Output is
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 133490,
"max_score": 0,
"hits": []
},
"aggregations": {
"effects": {
"buckets": [
{
"key": "snp",
"doc_count": 112918
},
{
"key": "indel",
"doc_count": 15725
},
{
"key": "mnp",
"doc_count": 3751
},
{
"key": "mixed",
"doc_count": 1096
}
]
}
}
}
When i count the individual count, the total tallies to 133490 (which is
the total number of docs in the colleciton.
But when i do the following query, i don't get the exact result count ( I
am using all the possible values which returned above and converted to an
OR query ) :
{
"query": {
"filtered": {
"filter": {
"and": [
{
"query": {
"filtered": {
"filter": {
"or": { "filters" : [
{
"query": {
"match": {
"type": "SNP"
}
}
},
{
"query": {
"match": {
"type": "INS"
}
}
},
{
"query": {
"match": {
"type": "DEL"
}
}
},
{
"query": {
"match": {
"type": "COMPLEX"
}
}
},
{
"query": {
"match": {
"type": "MNP"
}
}
},
{
"query": {
"match": {
"type": "MIXED"
}
}
}
] }
}
}
}
}
]
}
}
}
}
Output :
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 117765,
"max_score": 1,
"hits": [
.....]
}
}
As you can see the result hit count doesn't match the number of documents.
When i convert the above query from a match to "terms" based one, i get the
exact count.
{
"query": {
"filtered": {
"filter": {
"and": [
{
"query": {
"filtered": {
"filter": {
"and" : [{
"query": {
"terms": {
"type": ["snp", "mixed", "indel", "mnp"]
}
}
}]
}
}
}
}
]
}
}
}
}
Is this an issue with the OR query ?
Also, is there a suitable alternative with the match query where i could
easily represent the above query like :
{
"query" : {
"match" : { "type" : [ "snp", "mixed", "indel", "mnp" ] }
}
}
Any help is appreciated.
Thanks.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b466f820-d5cc-4a3b-a77a-79fe5aaa8ada%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.