Suppose you have data that includes an upper and a lower bound of some value.
<doc>
<lo>2</lo>
<hi>5</hi>
</doc>
How would you bucket these? Suppose we want to build facets like 1-4, 5-8, etc. This repo has code that demostrates how to do it.
To run this code, you will need to have MarkLogic installed. (Tested with ML7; ought to work with ML6+.) You will also need Ruby 1.9.3+ to run the Roxy Deployer. Then:
- if needed, identify some available ports on your MarkLogic instance. Defaults used here are 8060 and 8061. See deploy/build.properties.
$ ./ml local bootstrap$ ./ml local deploy modules
qconsole/ranged-buckets in a Query Console workspace. Go to http://localhost:8000/qconsole and import it. Execute the code in the buffer called "generate data". This will create 10,000 documents, each with random values for and elements, with the values in the range of [0..20].
You can execute the custom constraint through the REST API using these URLs:
http://localhost:8060/v1/search?options=startfinish.xml
http://localhost:8060/v1/search?options=finish.xml
http://localhost:8060/v1/search?options=lo.xml
Note that you may need to change the port if you configured your app server differently.