I am working on an existing Marklogic application that is written in XQuery. We currently have a bucket constraint to allow faceting on defined date ranges set-up like so:
<constraint name="date" xmlns="http://marklogic.com/appservices/search">
<range type="xs:gYear">
<element ns="http://digital.library.ptsem.edu/ia" name="date"/>
<bucket name="any-1800" lt="1801">–1800</bucket>
<bucket name="1801-1825" ge="1801" lt="1826">1801–1825</bucket>
<bucket name="1826-1850" ge="1826" lt="1851">1826–1850</bucket>
<bucket name="1851-1875" ge="1851" lt="1876">1851–1875</bucket>
<bucket name="1876-1900" ge="1876" lt="1901">1876–1900</bucket>
<bucket name="1901-1925" ge="1901" lt="1926">1901–1925</bucket>
<bucket name="1926-any" ge="1926">1926–</bucket>
</range>
</constraint>
Users currently have the option of selecting these date ranges by clicking the corresponding facets in the UI.
What I'd like to do is allow users to enter beginning and end dates in a form in order to search by custom date ranges. For example, they'd be able to type 1950 - 1970 in the text form and search this range. I'm thinking that these custom ranges can probably be implemented by removing the current date bucket constraint from search options and instead using range constraints so we can do something like (date-start:1800 AND date-end:1900) in the query text. Another option would be setting a bucket constraint on the fly, based on user-entered years.
I don't really know where to start or what the best approach would be. Has anyone done something similar or have a recommendation on how best to implement this?
Thanks!