Partial searches of datetime fields in Atlas

Hello,
Does Atlas allow partial searches in datetime fields? e.g. Searching for “june” in a given field should return all documents with “June” in the field.

Thanks,
Prasad

Hello,

Is this possible?

@Prasad_Kini Yes, Atlas Search allows partial searches in datetime fields. One way to achieve this is by using the $regex operator in the search query. For example, the query { $search: “june”, “dateField”: { $regex: “.June.” } } will return all documents with “June” in the “dateField” field. However, note that this approach may not be efficient for large datasets and it may be better to use a full-text search engine instead.

HTH

Hi @Deepak_Kumar16,
Thanks for the reply. The regex operator in $search doesn’t seem to support regex for dates - sample clause below. This clause filters out all the documents even when there are matching ones.

{ "regex": { "path": "created_on" , "query": ".*july.*", "allowAnalyzedField": true } }

Are you suggesting using $regex in the $match stage? If yes, this is not an option for us due to serious performance issues.

Thanks,
Prasad