I've just started to play a little bit around Solr and managed to get it running within a Tomcat servlet container. I would like now to use the repository approach from Spring Data but got stucked when trying to handle lat/lon fields (i.e.: geospatial data). I would like to store some tweet-like data. This is the schema I am currently using (trying to follow the wiki):
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="tweets" version="1.1">
<types>
<fieldType name="string" class="solr.StrField"/>
<fieldType name="text1" class="solr.TextField">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.HunspellStemFilterFactory"
dictionary="../../dictionaries/es_ANY.dic"
affix="../../dictionaries/es_ANY.aff"
ignoreCase="true" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text2" class="solr.TextField">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false"/>
<fieldType name="date" class="solr.DateField"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
</types>
<fields>
<field name="id" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="username" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="pictureURL" type="string" indexed="false" stored="true" multiValued="false"/>
<field name="topic" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="content" type="text1" indexed="true" stored="true"/>
<field name="hashtags" type="text2" indexed="true" stored="true"/>
<field name="geo" type="location" indexed="true" stored="true"/>
<field name="timestamp" type="date" indexed="true" stored="true"/>
<field name="_version_" type="long" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>id</defaultSearchField>
</schema>
This would work fine without the geo field, which I don't know how to map in my POJO (I tried both using double[] like MongoDB and String in geo field without much success):
public class Tweet {
@Id
@Field
private String id;
@Field
private String username;
@Field
private String pictureURL;
@Field
private String topic;
@Field
private String content;
@Field
private List<String> hashtags;
@Field
private String geo;
@Field
private Date timestamp;
/** Getters/setters omitted **/
}
When mapping the geo field as a simple String ([lat],[lng]) the exception thrown is:
org.springframework.data.solr.UncategorizedSolrException: undefined field: "geo_0_coordinate"; nested exception is org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: undefined field: "geo_0_coordinate"
I tried having a look at the project tests but did not find any POJO using geo fields.
Any idea on how to proceed?
Thanks!