Reputation: 38852
I have an object that I want to add to my Solr server that I've annotated using solrj's @Field annotation, but I can't find any documentation about what Java data type to use for Solr's location type. Here is my Bean I want to add:
@Field
private UUID id;
@Field
LatLonType location; // what should the Java data type of this field be???
@Field
private EventType eventType;
@Field
private int maxCapacity;
@Field
private int minCapacity;
@Field
private double price;
@Field
private Date startDate;
@Field
private Date endDate;
Any ideas?
Upvotes: 4
Views: 1894
Reputation: 38852
The best solution to the problem is if you want to use addBean() method(s) you'd create a property on the object and annotate that like so:
public class MyBean {
private double latitude;
private double longitude;
public String getLocation() {
return latitude + "," + longitude;
}
@Field
public void setLocation( String value ) {
String[] split = value.split(",");
latitude = Double.parseDouble(split[0]);
longitude = Double.parseDouble(split[1]);
}
}
Upvotes: 3
Reputation: 10750
The appropriate type on Java side is a simple String
with both the lat and lon separated by a comma, e.g. "1.2,3.4"
.
Upvotes: 4