New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
date field not search indexed #5626
Comments
You’ll probably have better luck working directly with the Date/Time field’s query param rather than going through search, which isn’t really intended for numerical/date values. |
Does this work in the CP as well? We are trying to find entries matching a certain date in a certain field. |
Good question. There’s currently no built-in way to set a Date/Time field’s query param from the control panel, but we’re working to make that possible in Craft 4. In the meantime, if you are running Craft 3.4.4.1 or later, you could add a date range picker to element indexes yourself, using the CP JS plugin and some custom JS code: // Is this the Entries index page?
if (Craft.elementIndex && Craft.elementIndex.elementType === 'craft\\elements\\Entry') {
// Add a date range picker to the toolbar
let startDate = endDate = null;
Craft.ui.createDateRangePicker({
onChange: function(s, e) {
startDate = s;
endDate = e;
Craft.elementIndex.updateElements();
},
}).appendTo(Craft.elementIndex.$toolbar);
// When the element index is updated, set our Date/Time field param
Craft.elementIndex.on('registerViewParams', function(event) {
event.params.criteria.myDateTimeField = ['and'];
if (startDate) {
event.params.criteria.myDateTimeField.push('>=' + (startDate.getTime() / 1000));
}
if (endDate) {
event.params.criteria.myDateTimeField.push('<' + (endDate.getTime() / 1000 + 86400));
}
});
} (Replace |
Works perfectly! Thanks! |
Description
We have a date field with search indexing enabled in certain entry types, but the keywords column in Craft's search index stays empty and the date is therefore not searchable.
Steps to reproduce
Please note we are using a multisite setup and the keyword column is empty for each multi site row in the searchindex table.
Additional info
The text was updated successfully, but these errors were encountered: