How to filter within a nested Property without change the result


(Dominik Malsch) #1

Hey,

how can i filter within a nested Property without change the result count?

Hit Example:

"_index": "1000",
"_type": "example",
"_id": "1337",
"_score": 1234,
"_source": {
    "id": 1337,
    "texts": [
        {
            "name": "FooBar",
            "lang": "de",
            "referrer":1
        },
        {
            "name": "FooBar",
            "lang": "de",
            "referrer":2
        },
        {
            "name": "FooBar",
            "lang": "en",
            "referrer":1
        },

But I just want certain text, filter by referrer and lang for every hit without to filter any other values of the hits.

I running on version 2.3 on AWS

Thanks helping me,
Dominik Malsch


(Dominik Malsch) #2

Push. Is this even possible?


(Adrien Grand) #3

What does your query look like so far?


(Dominik Malsch) #4

I have no query so far, because i want to now this function exist.


(Adrien Grand) #5

OK, got it. Then you might want to look at the nested type in the mapping.

Note that depending on your use-case, an alternative could be to denormalize your documents to look like:

{
    "parent_id": 1337,
    "name": "FooBar",
    "lang": "de",
    "referrer":1
}

And then run a cardinality aggregation to compute the number of unique parent_ids.


(system) #6

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