Hi, i've got this to work. Maybe this info can be useful to others so I post it here...
I had to implement a 'FieldBridge' that transforms the coordinates to a sortable String.
In the org.apache.solr.util.NumberUtils class there is a method that does this.
The implementation of the FieldBridge is below...
Code:
import org.apache.solr.util.NumberUtils;
import org.hibernate.search.bridge.StringBridge;
/**
*
* @author Fred
*/
public class GeoCoordinateFieldBridge implements StringBridge {
public String objectToString(Object object) {
if(object != null && object instanceof Double)
{
Double coordinate = (Double)object;
return NumberUtils.double2sortableStr(coordinate);
}else
{
return "";
}
}
}
You then have to apply this 'bridge' to the latitude and longitude fields:
Code:
@Column
@Field(index=Index.UN_TOKENIZED, store=Store.YES)
@FieldBridge(impl = GeoCoordinateFieldBridge.class)
private Double latitude;
To index the entities nothing changes.
To launch the search, I used the code that can be found in the README file of the locallucene distribution.
Best regards,
Fred