Hi!
I use ES for a project where you have a telephone book but users can alter the original entries for their group or just themselves. The user can search the telephone book for entries but only wants to see the entries that are valid for him in his group context. So, my search looks like this:
GET etb/_search?pretty
{
"query": {
"bool": {
"must": [
{
"match_phrase_prefix" : {
"_all" : "Max"
}
},
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"match": {
"ownerType": "USER"
}
},
{
"match": {
"owner": 1
}
}
]
}
},
{
"bool": {
"must": [
{
"match": {
"ownerType": "GROUP"
}
},
{
"bool": {
"should": [
{
"match": {
"owner": 5
}
},
{
"match": {
"owner": 3
}
},
{
"match": {
"owner": 1
}
}
]
}
}
]
}
}
]
}
}
]
}
},
"aggs" : {
"distinctIds" : {
"terms" : {
"field" : "id.keyword",
"size": 2147483647
}
}
},
"size": 0
}
I know it's a little monster ;D But what I want to achieve here is, of course do a kind of "wildcard search" over all fields for the name "Max", and to make sure the entries should at least contain either my user id as an owner or one of my group ids. But I don't want the actual entries, just the distinct ids so I can afterwards join the entries.
The problem here is that I only get 126 or 138 or 141 buckets although I know there must be 10.315 matches. And what would happen if the matches will be > Integer.MAX_VALUE?
Is this even the right way to get what I want?
Thanks in advance =)