Filter/Collapse on multiple fields

Hi all,

I'm trying to find documents that have distinct values over 2 separate fields.
Documents have _id, filters.10,filters.20

For Example:

    1, f10_1, f20_1
    2, f10_1, f20_1
    3, f10_2, f20_1
    4, f10_3, f20_2

what I'm trying to find is:

    1, f10_1, f20_1
    4, f10_3, f20_2

2 documents that have bot filters.10 and filters.20 distinct

collapse only works on one field...

I tried:

{
  "size":3,
  "aggs": {
    "uniq_10": {
    "terms": {
        "script": "doc['filters.10'].value+doc['filters.20'].value",
      }
    }
  }
}

but it doesn't do what I need :frowning:

any tips are welcome

Thanks

just for clarification, filters.10 and filters.20 are the field names:

ID,filters.10,filters.20
1 , f10_1    , f20_1
2 , f10_1    , f20_1
3 , f10_2    , f20_1
4 , f10_3    , f20_2

instead of using your shortened syntax a fully reproducible example including index creation/mapping, document creation and query might help a lot here for others to create a proper context.

Thank you!

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