You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by nick19701 <to...@yahoo.com> on 2007/04/02 20:06:52 UTC

Find docs close to a date

Let me use this date for example:
2007-03-25T17:22:00Z

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?
-- 
View this message in context: http://www.nabble.com/Find-docs-close-to-a-date-tf3507295.html#a9795867
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Find docs close to a date

Posted by nick19701 <to...@yahoo.com>.

Chris Hostetter wrote:
> 
> 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.
> 
> 

Yes, I'm looking for "the doc with the latest date prior to my input, 
and the doc with the earliest date after my input", not "the two docs 
with a date which is closest to my input".

One application of this is to determine email's signature.
One person's email signature may change over time. So I only want
to compare one email with the emails immediately before or after
this one.

I haven't written any java code yet. But maybe someday I will
try for this one.

-- 
View this message in context: http://www.nabble.com/Find-docs-close-to-a-date-tf3507295.html#a9858867
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Find docs close to a date

Posted by Chris Hostetter <ho...@fucit.org>.
: 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