Filter by object values inside array

Hi, I have an array with this format inside every record:

open_groups: [
  {start: 10/10/2022, end: 11/10/2022},
  {start: 20/10/2022, end: 21/10/2022},
  ...
]

How can I filter for start and end? For example, I have an user input with values for start and end, and I want to show all the records that have this match in the open_groups array.

I’m using this component:

<Configure hitsPerPage={18} filters="hasOpenGroups:true" />

But I don’t know how to pass the filter that I want.

Thanks.

@development9 welcome to the community!

If you convert the dates to the Unix epoch equivalent you should be able to do what you are looking to do.

Record example:

{
  "open_groups": [
    {"start": 1666043520, "end": 1666045520},
    ...
  ],
  ...
}

Filter example: open_groups.start >= 1666043520 AND open_groups.end <= 1666045520

You can find more information on how Algolia filters with dates here in our documentation.

Let me know how this works for you, happy to help further! Thanks!

Hi Michael, just a quick additional question.
We follow a pattern here, so to speak, 1 real value and 2 values in the index. Correctly?

1 value for displaying in nice form, attributesToRetrieve
2 Value for high-performance searching/filtering, searchableAttributes

Or in the case of development9 would be even better:
we have only one value in the index, both searchableAttributes and attributesToRetrieve, and programmatically format it in our application.

Right?

I think 2 values for an in array is overkill.
Filtering by timestamp and formatting programmatically should be ok.