Foros de discusión

Search Geo Location Range

thumbnail
Andrew Jardine, modificado hace 7 años.

Search Geo Location Range

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Sigh. My friday was going to so well, until about 15 minutes ago. I'm really hoping that someone out there (maybe from the Liferay search team) can help me with this one.

I have a whole pile of location records with a lat field and a long field. I am creating these records in the system using WCM. I have the lat and the long structure fields set to be indexed, so I can see their values in my lucene index when i use Luke. Problem is that my range queries are not working -- I am basically getting back ALL my records all the time. I did some digging and reading and found this very disheartening post --

http://chase-seibert.github.io/blog/2009/09/11/numeric-range-searches-in-lucene.html

While it was interesting to read, and a very clear explanation of the problem and one possible solution to solve it, I'm not crazy about the idea of doing this. If nothing else it distorts the geo values to the point where they have basically no meaning unless you go through the site to get them. Yes, yes, I know I could store the values in another field and just search that one, leave the regular lat/long as the legible ones-- but there MUST be another way to solve this.

I noticed that there is the option on the BooleanQuery to addNumericRangeTerm, but it only supports whole numbers (short, int, long) .. and I need the precision of the floating points.

Can anyone help? Does anyone have any suggestions for me to try?
thumbnail
David H Nebinger, modificado hace 7 años.

RE: Search Geo Location Range

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
Yeah, it's actually not easy using lucene queries because of the string content.

Often times what folks want to do here is like a radial search around a point, "what is within 50 miles of x", but sometimes you also have to take into account that your point is on a sphere and that can affect radial distance depending upon how large a scale you're going.

Many modern databases actually will support distance queries around a point using table data. I'm wondering if you wouldn't be better served leaving this query in the DB and leveraging whatever facilities your database supports.
thumbnail
Andrew Jardine, modificado hace 7 años.

RE: Search Geo Location Range

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Hey David,

Thanks for replying. The application that I am working on is pretty search intensive so I wanted to use a proper search engine to maximize the query speed. The other problem with querying the database is that I am storing the locations as JournalArticles ... so of course the details are stored in that XML structure.

I used the code from the link I posted and updated my solution so that my search index has the inverted double values. So now I have .. for example...

query:
+entryClassName:com.liferay.portlet.journal.model.JournalArticle +status:0 +companyId:20155 +scopeGroupId:20182 +ddmStructureKey:21233 +folderId:20546 +head:true (+ddm/20551/searchLatitude_en_US:[p99999999999956d44287871 TO p99999999999956d50510787])

But I am still getting all my docs (sample data) back. You used to be able to configure the query analyzer that lucene used... can you not do that (in 6.2) anymore?
thumbnail
David H Nebinger, modificado hace 7 años.

RE: Search Geo Location Range

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
I don't think that has been stripped functionality, but I haven't configured an analyzer myself, but have you tried this under solr? Personally I hate doing much of anything in lucene...
thumbnail
Andrew Jardine, modificado hace 7 años.

RE: Search Geo Location Range

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Hey David,

Believe it or not, I got it to work -- lol. It was probably the worst 5 hours of my life as everything I tried failed, but then I finally figured it out. It's way to much to write out here, so I am going to write a blog post and update this thread with the link. Suffice to say that in the end, it was, of course, super simple -- as is usually the case.

Thanks again.
thumbnail
David H Nebinger, modificado hace 7 años.

RE: Search Geo Location Range

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
Cool! Looking forward to reading about it...
thumbnail
Jack Bakker, modificado hace 7 años.

RE: Search Geo Location Range

Liferay Master Mensajes: 978 Fecha de incorporación: 3/01/10 Mensajes recientes
I'm looking forward to reading it too. Now the pressure is on Andrew... lol