Hi there!
Long story short:
Is there a way to retrieve every result of a terms facet? Something like "size"
: "_all"? Or do I have to trick and use "size" : 9999999?
Long story long:
I have a bunch of documents that look like this:
{
"signature" : "something",
"os" : "linux" // or "windows" or "mac"...
}
The signature field is not analyzed. There are other fields that don't
matter here. Documents can share the same signature, and that is the point.
What I am trying to do is getting the distinct signatures, and for each
signature the total count and the count by OS. My solution so far is to
query (I actually search things in the other fields, but it doesn't matter
here) a bunch of documents, and apply terms facets.
Here is what my JSON query looks like:
{
"size" : 0,
"query" : {
"match_all" : {}
},
"facets" : {
"sign" : {
"terms" : {
"field" : "signature"
}
},
"sign_win" : {
"terms" : {
"field" : "signature"
},
"facet_filter" : {
"term" : {
"os_name" : "windows"
}
}
},
...
}
This works. This gives me almost the data I want. The last problem is that I
need to get only a part of this big set of data. I want to be able to do
something similar to a "size" / "from" but for the facet. And if, as I
believe, it is not possible with ES, I would like to retrieve every result
of the facets, and then apply the size / from in my code.
Am I doing it wrong? Is there something I don't know about that would solve
my problem? What is the Ultimate Question of Life, the Universe, and
Everything?
Thanks for your help!
--
Adrian Gaudebert
WebDev Intern @ Mozilla
http://adrian.gaudebert.fr