lets say I have a docs in an elastic index, and I query it with some term - FEILD_1:VALUE1.
now, I get Y results, and I want to know how many of those results has FEILD2:VAL2.
I don't want only the docs that match both (or I would use filter or another match), I want all the docs that match the first term query, but I'm interested in the number of the results that also match the second condition (only the number, not the results themselves).
Is there a way to achive that?
I would do a query like this field1:valueX AND field3:valueY. I think this would meet your needs unless I am understanding the question incorrectly
Query for field1:value1 but add a ‘terms’ aggregation on the “field2” field with an “include” parameter set to “value2”
Sorry I didn’t read your question carefully. I think Mark is definitely right on this. Another approach is that you can use is use chain - transform which seems more complex than it needs to be so I think Mark’s answer might be the best solution for your problem
will this terms aggs will be applied to the results of the query or will it run along side the query on the general index?
The full set of docs matching the query (not just the top scoring subset returned in “hits”)
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.