SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye

Welcome, Guest
Guest Settings
Help

Compass Support Forums » Compass » Compass Users

Thread: Negative double indexed as positive

This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Pages: 1 - Last Post: Mar 23, 2008 2:29 PM Last Post By: Maurice Nicholson
Mike Brevoort

Posts: 1
Registered: 2/6/08
Negative double indexed as positive
Posted: Feb 6, 2008 7:26 PM
 
  Click to reply to this thread Reply
I'm pretty green when it comes to Compass so excuse me in advance :) I'm using the Grails Searchable plugin to index a domain class that has a double value with negative numbers. Compass/Lucene however is storing this in the index (using Luke to inspect the index) as a positive number so my range queries are returning no results when I search over the negative range.

I have a feeling that I need to use a converter, but I don't know where to start to configure it. Any words of wisdom?

Thanks,
Mike
http://mike.brevoort.com

Edited by: Mike Brevoort on Feb 6, 2008 8:52 PM
Shay Banon

Posts: 4,028
Registered: 9/6/05
Re: Negative double indexed as positive
Posted: Feb 7, 2008 12:52 PM   in response to: Mike Brevoort in response to: Mike Brevoort
 
  Click to reply to this thread Reply
You can extend AbstractBasicConverter and do the conversion yourself. I suggest you take a look at some of the simple converters on how to do it. Later on, you can configure a custom converter with Compass and reference it for the mappings you want to apply it to. Here is an example of how this can be done: http://www.compass-project.org/docs/1.2.1/reference/html/core-settings.html#config-converter. The forum should have a lot of examples as well...
Conor Dickinson

Posts: 1
Registered: 2/13/08
Re: Negative double indexed as positive
Posted: Feb 13, 2008 12:27 AM   in response to: Mike Brevoort in response to: Mike Brevoort
 
  Click to reply to this thread Reply
Mike, did you figure out a solution to this problem? I'm running into the same issue with latitude and longitude in my Grails domain classes. It seems to me like this is just a bug, since it should be using the default FloatConverter, which I would think should handle negative numbers correctly.

Also, where does the Searchable plugin store the index by default? I can't seem to find it anywhere.

Thanks,
Conor
Maurice Nicholson

Posts: 55
Registered: 12/13/06
Re: Negative double indexed as positive
Posted: Mar 23, 2008 2:00 PM   in response to: Conor Dickinson in response to: Conor Dickinson
 
  Click to reply to this thread Reply
As I replied on the Grails user list this is probably because the number property is being "tokenized" which normalises text (by lower-casing, striping punctuation, etc).

I wrote up the solution here: http://grails.org/Searchable+Plugin+-+FAQ#SearchablePlugin-FAQ-Negativenumbersareindexedaspositive

(Of course Compass offers this functionality in the first place (that's where the Grails Searchable Plugin gets it) so the solution is similar for Compass.)

I am beginning to think that the plugin should set index="un_tokenized" to be the default for certain property types, eg, boolean, number, enum, and allow the user to override it if required.

I believe the behaviour that results from this will be what most users will expect. Anyone care to comment?
Shay Banon

Posts: 4,028
Registered: 9/6/05
Re: Negative double indexed as positive
Posted: Mar 23, 2008 2:11 PM   in response to: Maurice Nicholson in response to: Maurice Nicholson
 
  Click to reply to this thread Reply
That is actually a very interesting idea. I agree that most times the default index for numbers should be un_tokenized. Care to open a jira issue and I will see what can be done. The main problem with this is the fact that it breaks backward compatibility in Compass, but if I manage to get it to 2.0, with a flag to revert to the old behavior, I think it is acceptable.
Maurice Nicholson

Posts: 55
Registered: 12/13/06
Re: Negative double indexed as positive
Posted: Mar 23, 2008 2:29 PM   in response to: Shay Banon in response to: Shay Banon
 
  Click to reply to this thread Reply
Awesome!

http://issues.compass-project.org/browse/ CMP-590

Cheers Shay!
Legend
Guru: 2001 + pts
Expert: 501 - 2000 pts
Super-star: 101 - 500 pts
Assistant: 51 - 100 pts
Participant: 0 - 50 pts
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums