lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yang Yang <>
Subject lucene anchor-distance based search
Date Thu, 18 Nov 2010 02:08:57 GMT
We are using the hibernate search which is based on lucene as the search
engine to build a full text search for our position-related data in the
This is the main structure of the table(it save the id,coordinate and name
of one Surface_Feature):
| id | co_x   | co_y    | name       |
|  1 | 11111  | 22222   | Disney Park|
Then these attributes are mapped as the fields in lucene by hibernate
search.And I do the following configuration to the field:
field_co_x -->Store.Yes,Index.UN_TOKENIZED.
field_co_y -->Store.Yes,Index.UN_TOKENIZED.
field_name -->Store.Yes,Index.TOKENIZED.

Then we want to query the Surface_Features basing on a special scope.

For example:
1) Range search
if we want to search the Surface_Feature whose co_x  is between [minX,maxX]
and whose iny is between [minY,maxY],for this requirement I thought the
--code snippet--

        TermRangeQuery trq_x=new TermRangeQuery("co_x ", minX, maxX, ture,
        TermRangeQuery trq_Y=new TermRangeQuery("co_y", minY, maxY, ture,

        BooleanQuery query=new BooleanQuery();
        query.add(trq_x, BooleanClause.Occur.MUST);
Is this right?

2) Anchor-distance based search
But I have no idea about how to query features basing on a anchor and a

That'to say I want to search features who are located inside the circle
defined by the anchor and the distance.

It seems that the sphinx provide a function named SetGeoAnchor(),so I wonder
if lucene can implement the same requirement?

BWT,for some condition-required search I can make the condition as a filter
and then filter the result.

Also I can build a BooleanQuery according to the condition just like the
code in the range search,I wonder which is better?

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