Hi,
I am struggling with a simple date filtering and not sure if I am doing the filtering wrong or missing something in my configuration.
I have the following document being indexed:
{
"_class": "com.package.User",
"email": "jdoe@email.com",
"createdBy": "system",
"createdAt": 1614905631637,
}
and trying to filter by createdAt field
The filter by date code looks as:
...
if (createdAtStart != null || createdAtEnd != null) {
DateRangeQuery dateRangeQuery = SearchQuery.dateRange();
if (createdAtStart != null) {
dateRangeQuery = dateRangeQuery.start(createdAtStart.toInstant(), true);
}
if (createdAtEnd != null) {
dateRangeQuery = dateRangeQuery.end(createdAtEnd.toInstant(), true);
}
searchQueries.add(dateRangeQuery.field("createdAt"));
}
And the query that is being executed is:
{"conjuncts":[{"field":"_class","match_phrase":"com.package.User"},{"start":"2021-03-04T01:09:39.422Z","end":"2021-03-06T01:09:39.422Z","inclusive_start":true,"inclusive_end":true,"field":"createdAt"}]}
That query returns no results.
My index definitions is:
{
"type": "fulltext-index",
"name": "search_idx",
"uuid": "2426c752dcfa607c",
"sourceType": "couchbase",
"sourceName": "identity",
"sourceUUID": "1990e653ab4a86458102e5cee0fcdd3f",
"planParams": {
"maxPartitionsPerPIndex": 171,
"indexPartitions": 6
},
"params": {
"doc_config": {
"docid_prefix_delim": "",
"docid_regexp": "",
"mode": "type_field",
"type_field": "type"
},
"mapping": {
"analysis": {},
"default_analyzer": "standard",
"default_datetime_parser": "dateTimeOptional",
"default_field": "_all",
"default_mapping": {
"dynamic": true,
"enabled": true
},
"default_type": "_default",
"docvalues_dynamic": true,
"index_dynamic": true,
"store_dynamic": false,
"type_field": "_type"
},
"store": {
"indexType": "scorch"
}
},
"sourceParams": {}
}
I also tried adding a Date/Time Parser but that didn’t work either.
I was thinking that maybe the problem is that I am storing the date as Long since I am using java.util.Date?
Thanks!