: My docs have a date field and I need to find the two docs with : a date which is closest to 2007-03-25T17:22:00Z. : : I use the following two queries to accomplish the task. : : date:{* TO 2007-03-25T17:22:00Z};date desc&start=0&rows=1 : date:{2007-03-25T17:22:00Z TO *};date asc&start=0&rows=1 : : However I need to make a lot of queries like these. I'm wondering if : these kinds queries are expensive. Are there better alternatives for my : task?
off the top of my head, i can't think of any better way to do what you are doing "out of hte box" with Solr ... if you wanted to write a bit of custom java code, a FunctionQuery ValueSource that made a "bell curve" arround a particular value would be a very cool/vlearn/reusable solution to this problem. One thing to watch out for is that this gives you the doc with the latest date prior to your input, and the doc with the earliest date after your input -- which is not exactly "the two docs with a date which is closest to" ... the two docs with the "closest" dates might have dates both below hte input, or both above the input. -Hoss