And vs or terms?


I have a question about using a terms query while specifying an array of potential values. It seems to me the query uses a boolean or to match and I would like it to use a boolean AND... for example, consider this query fragment:

                                    "bool": {
                                        "must": [
                                                "nested": {
                                                    "path": "document.section",
                                                    "query": {
                                                        "terms": {
                                                            "document.section.flags": [

When I execute this query, I end up getting results that have just full-time instead of getting only results that have full-time and settlement-summary. I've been googling around and can't seem to find a way to change that behavior?



Looking at what you're trying to do, I think what you want to do is use the bool query and then use a must clause there. I also think you really want the must clauses to be a term query rather than a terms query from what I see here.

I'll try adding the bool must, but based on what I was reading why would I want to use a collection of 'term' instead of just an array of terms? Without dumping the (large) mapping, basically this particular field is a comma-separated list of flags (and those flags are parsed by ES)


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.