Skip to content

Switch to using DateRangeField for storing date ranges#330

Draft
jcoyne wants to merge 1 commit intomainfrom
date_range_field
Draft

Switch to using DateRangeField for storing date ranges#330
jcoyne wants to merge 1 commit intomainfrom
date_range_field

Conversation

@jcoyne
Copy link
Member

@jcoyne jcoyne commented Feb 6, 2026

This can be more efficient than a long list of integers.

This can be more efficient than a long list of integers.
@jrochkind
Copy link
Member

Would the UI look any different, or the same? Would this PR make it possible to use dates more specific than years, or not yet?

Would it still possible to use this plugin with integers that are not dates, if desired? I know the bulk of the use of this is with integers representing years, but I'm not sure if some may be using it for other integer content, which was always meant to be supported.

@gwiedeman
Copy link

I tested this with some very mixed success unfortunately. I have a branch here that seems to be successfully indexing date_range_drsi. I see "date_range_drsi":"[1900 TO 2014]", in my Solr index (still solr 8.6.0 if that matters). I am able to query date_range_drsi:1910 both in the Solr console and in Arclight with a ?q=date_range_drsi:1910 param.

However, searching ?q=1910&search_field=all_fields does not return the result I expect as its not in text. I don't think I can <copyField source="date_range_drsi" dest="text" /> because its not text, but I haven't tried that.

For the plugin, I put gem "blacklight_range_limit", git: 'https://github.com/projectblacklight/blacklight_range_limit', branch: 'date_range_field' in my Gemfile and config.add_facet_field 'date_range', field: 'date_range_drsi', range: true in my catalog_controller.rb but returning just an empty search yields this error:

Blacklight::Exceptions::InvalidRequest in CatalogController#index
RSolr::Error::Http - 400 Bad Request
Error: A ValueSource isn't directly available from this field. Instead try a query using the distance as the score.
URI: https://localhost:8984/solr/arclight-test/select?wt=json&rows=10&fl=*%2Ccollection%3A%5Bsubquery%5D&collection.q=%7B%21terms+f%3Did+v%3D%24row._root_%7D&collection.defType=lucene&collection.fl=*&collection.rows=1&facet=true&facet.field=has_online_content_ssim&facet.field=repository_ssim&facet.field=collection_ssim&facet.field=date_range_drsi&facet.field=access_subjects_ssim&facet.field=creator_ssim&facet.field=level_ssim&facet.field=names_ssim&facet.field=geogname_ssim&facet.field=parent_ssi&f.has_online_content_ssim.facet.limit=11&f.repository_ssim.facet.limit=11&f.collection_ssim.facet.limit=11&f.access_subjects_ssim.facet.limit=11&f.creator_ssim.facet.limit=11&f.level_ssim.facet.limit=11&f.names_ssim.facet.limit=11&f.geogname_ssim.facet.limit=11&f.parent_ssi.facet.limit=11&sort=score+desc%2C+title_sort+asc&json.facet=%7B%22date_range_drsi_range_stats%22%3A%7B%22type%22%3A%22query%22%2C%22q%22%3A%22*%3A*%22%2C%22facet%22%3A%7B%22min%22%3A%22min%28date_range_drsi%29%22%2C%22max%22%3A%22max%28date_range_drsi%29%22%2C%22missing%22%3A%7B%22type%22%3A%22query%22%2C%22q%22%3A%22-date_range_drsi%3A%5B*+TO+*%5D%22%7D%7D%7D%7D&hl=true&hl.fl=text&hl.snippets=3&group=true&group.field=_root_&group.ngroups=true&group.limit=3
Backtrace: /usr/local/bundle/gems/rsolr-2.6.0/lib/rsolr/client.rb:220:in `rescue in execute'
/usr/local/bundle/gems/rsolr-2.6.0/lib/rsolr/client.rb:208:in `execute'
/usr/local/bundle/gems/rsolr-2.6.0/lib/rsolr/client.rb:203:in `send_and_receive'
/usr/local/bundle/gems/blacklight-8.4.0/lib/blacklight/solr/repository.rb:71:in `block in send_and_receive'
/usr/local/bundle/gems/activesupport-7.2.3/lib/active_support/benchmarkable.rb:44:in `block in benchmark'
/usr/local/bundle/gems/benchmark-0.5.0/lib/benchmark.rb:337:in `ms'
/usr/local/bundle/gems/activesupport-7.2.3/lib/active_support/benchmarkable.rb:44:in `benchmark'
/usr/local/bundle/gems/blacklight-8.4.0/lib/blacklight/solr/repository.rb:70:in `send_and_receive'
/usr/local/bundle/gems/blacklight-8.4.0/lib/blacklight/solr/repository.rb:33:in `search'
/usr/local/bundle/gems/blacklight-8.4.0/app/services/blacklight/search_service.rb:34:in `search_results'
/usr/local/bundle/gems/blacklight-8.4.0/app/controllers/concerns/blacklight/catalog.rb:26:in `index'

This was using our customized ArcLight so I'm not 100% that there's not some other issue with that, but it seems to work when I switch catalog_controller.rb back to use date_range_isim.

The Solr 9 docs for DateRangeField says "It has the potential to allow efficient faceting, similar to facet.enum." but I don't know what that means?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants