views:

154

answers:

1

Hey SO,

I'm running Zend_Search_Lucene, which is almost exactly the same as normal Lucene. I'm keeping stores in my Lucene index, and they're holding this:

id of store for sql - 'store_id' of field type keyword

name of store - 'name' of field type text

latitude of store - 'lat' of field type keyword

longitude of store - 'lng' of field type keyword

I only have one store to test in the database. It has name "the super awesome store", has an index of 11, lat of 73.9, and lng of 40.6. However, the results aren't working like they should.

Here is an example of one of my queries that doesn't work:

(name:'awesom*') AND lat:[-74.486951 TO -73.486951] AND lng:[40.256054 TO 41.256054]

The * is supposed to represent "and then anything you want", and it won't return the store. If I make name "awesome*", it will return correctly. I don't know how to make it search for awesomatic/awesome/etc.

My other problem is that the lat and lng search aren't working either. They don't seem to matter, no matter what the span of lat or lng is. Even if I put in the lat/lng of china, as long as the name matched, it returns the result. I need it to only return the result if that lat and lng are within their correct ranges.

What am I doing wrong?! Please help!

+1  A: 

Please see this question about geo-search in Lucene. I believe indexing and searching float values will not work. Try Making these large, zero padded integers. e.g.

lat:[-74486951 TO -73486951]

This could have a detrimental effect in terms of performance, so consider using a lower resolution, or use some techniques from This question, which discusses indexing longitude and latitude data in Java Lucene (Zend Lucene is a bit behind in versions, so try to use the older stuff).

Yuval F