lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From KEGan <khoon.ee....@gmail.com>
Subject Number Proximity Query
Date Wed, 04 Oct 2006 00:51:10 GMT
Hi,

Is there a way to query all numbers that is close to a particular number
(query), and score by how close they are to that number (query) ?

To illustrate further, assume document with single field "num", and the
value for this field can only be integer number. Now, let says, there are 3
documents (doc1, doc2, doc3) with the following "num" values .... 1, 10, and
100. Hence if we query for 12, the return results should be order by doc2,
doc1, doc3. Since 10 is closer to 12, follows by 1, and finally follows by
100.

Is there a way to do this easily in Lucene ?

>From my searches, there seems to be a FunctionQuery in Solr that can do this
type of query. But I am using pure Lucene, and trying to port Solr code over
(to create my own version of FunctionQuery) looks too complicated because of
code dependency on other Solr code such as ValueSource, etc.

I have also search on how to write my own query instance, but there is lack
of documentation on doing so. The formula to calculate the number proximity
is quite trivial. But how to stitch together Query, Weight, Scorer is the
problem :(

Any suggestion is greatly appreciated :)

~KEGan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message