Filtering - string comparison #639
Replies: 4 comments 6 replies
-
Hey, sorry for the inconvenience. In the meantime, even if it's not ideal, maybe you could store your dates as a unit timestamp in meilisearch? |
Beta Was this translation helpful? Give feedback.
-
@gmourier is there any workaround for the above issues? Or is storing dates as timestamps the only option to compare them? |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, there are issues with nanosecond precision in the Unix timestamp solution. To go over this in more details: |
Beta Was this translation helpful? Give feedback.
-
I ended up transforming Strapi data do Meilisearch format using a transforming function described in the |
Beta Was this translation helpful? Give feedback.
-
It would be really nice to be able to compare string fields using filters. I'm thinking about comparing ISO dates, but there are many other circumstances when this might be needed. Here are my use cases:
Filter date field by month:
This is doable by generating all days in month and using IN operator:
startDate IN ['2023-04-01', '2023-04-02', ..., '2023-04-30']
But this would be so much easier using string comparison:
startDate >= '2023-04-01' AND startDate <= '2023-04-30'
or even:
startDate '2023-04-01' TO startDate '2023-04-30'
Filter only future dates
The above solution won't work here; there's no point in generating an arbitrary number of future dates and using IN operator. Date comparison would be really simple:
startDate > '2023-04-04'
. Same thing goes for filtering on ISO datetime fields.Without this feature we're not able to implement user-defined filters our site needs. It's a shame, cause using Meilisearch was a really smooth experience up until this point 😄 really wouldn't want to switch back to Elasticsearch
Beta Was this translation helpful? Give feedback.
All reactions