FAQ
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
MYSQL db.
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
RangeTermQuery.
--code snippet--

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

BooleanQuery query=new BooleanQuery();
query.add(trq_x, BooleanClause.Occur.MUST);
query.add(trq_Y,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
distance.

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?

Search Discussions

  • Anshum at Nov 18, 2010 at 5:42 am
    Hi.
    The way you're forming the BooleanQuery seems fine to me (minus the ture
    should've been true, and 'm guessing its a typo).
    About the geo-spatial search, you may have a look at the various approaches
    there are for the same. Have a look at the contrib module in lucene.
    http://wiki.apache.org/lucene-java/SpatialSearch
    For your understanding, you could have a look at the bounding box approach.

    --
    Anshum Gupta
    http://ai-cafe.blogspot.com

    On Thu, Nov 18, 2010 at 7:38 AM, yang Yang wrote:

    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
    MYSQL db.
    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
    RangeTermQuery.
    --code snippet--

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

    BooleanQuery query=new BooleanQuery();
    query.add(trq_x, BooleanClause.Occur.MUST);
    query.add(trq_Y,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
    distance.

    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?
  • yang Yang at Nov 18, 2010 at 7:06 am
    Thank you very much!!! :)

    I will have a look at the docs .

    2010/11/18 Anshum <anshumg@gmail.com>
    Hi.
    The way you're forming the BooleanQuery seems fine to me (minus the ture
    should've been true, and 'm guessing its a typo).
    About the geo-spatial search, you may have a look at the various approaches
    there are for the same. Have a look at the contrib module in lucene.
    http://wiki.apache.org/lucene-java/SpatialSearch
    For your understanding, you could have a look at the bounding box approach.

    --
    Anshum Gupta
    http://ai-cafe.blogspot.com

    On Thu, Nov 18, 2010 at 7:38 AM, yang Yang wrote:

    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
    MYSQL db.
    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
    RangeTermQuery.
    --code snippet--

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

    BooleanQuery query=new BooleanQuery();
    query.add(trq_x, BooleanClause.Occur.MUST);
    query.add(trq_Y,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
    distance.

    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?
  • yang Yang at Nov 18, 2010 at 11:03 am
    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?

    2010/11/18 yang Yang <m4eclipse@gmail.com>
    Thank you very much!!! :)

    I will have a look at the docs .

    2010/11/18 Anshum <anshumg@gmail.com>

    Hi.
    The way you're forming the BooleanQuery seems fine to me (minus the ture
    should've been true, and 'm guessing its a typo).
    About the geo-spatial search, you may have a look at the various
    approaches
    there are for the same. Have a look at the contrib module in lucene.
    http://wiki.apache.org/lucene-java/SpatialSearch
    For your understanding, you could have a look at the bounding box
    approach.

    --
    Anshum Gupta
    http://ai-cafe.blogspot.com

    On Thu, Nov 18, 2010 at 7:38 AM, yang Yang wrote:

    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
    MYSQL db.
    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
    RangeTermQuery.
    --code snippet--

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

    BooleanQuery query=new BooleanQuery();
    query.add(trq_x, BooleanClause.Occur.MUST);
    query.add(trq_Y,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
    distance.

    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?

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedNov 18, '10 at 2:08a
activeNov 18, '10 at 11:03a
posts4
users2
websitelucene.apache.org

2 users in discussion

yang Yang: 3 posts Anshum: 1 post

People

Translate

site design / logo © 2022 Grokbase