I'm currently trying to use a filter
in an existing ElasticSearch instance via the library elasticutils
. I'm getting nowhere, unfortunately. I'm not sure if the problem is because I did something basic wrong or if there's a problem in the library (could well be, AFAICT).
I've got an index with a specific mapping, containing a field (say "A") of type string (no explicit analyzer given). That field always contains a list of strings.
I'd like to filter my documents by containing a given string in that field A, so I tried:
import elasticutils as eu
es = eu.S().es(urls=[ URL ]).indexes(INDEX).doctypes(DOCTYPE)
f = eu.F(A="text")
result = es.filter(f)
But that returns an empty result set. I also tried it using f = eu.F(A__in="text")
but that resulted in a large error message, the most intriguing part of it being [terms] filter does not support [A]
.
I'm wondering if I have to configure my index differently, maybe I have to create a facet to be able to use filter? But I didn't find any hint on this in the documentation I read.
My reason for wanting to use filter
is that they can be combined freely using and
, or
, and not
. I also found some specs describing that query
also can be boolean, but they typically refer to must
, should
, and must_not
which aren't flexible enough for me I think. But I also found some specs which mentioned an operator
flag for query
s which can be set to and
or or
. Any info on that is welcome.
So, my questions now are:
- Is it a configuration problem? Do facets have something to do with this?
- I'd like to test whether this is a library bug by skipping the lib, so how can I perform this filtering action using just, say, curl? Or any other library (maybe
pyes
)? - Is a flexible combining (using
and
,or
,not
, and groupings of them) of several queries possible (i. e. without using filters at all)? How would I do that? (Preferably inelasticutils
but other library syntaxes, e. g.pyes
, or simple CURLs are welcome as well).