如何将地图存储在Solr中的POJO中?目前,我有这样如何将地图存储在Solr的POJO中?
@Field("*_locId")
protected Map<String, Integer> geoLocationToLocationId;
在Schema.xml文件的构建:
<dynamicField name="*_locId" type="int" indexed="false" stored="true" multiValued="false" />
通过添加:
public void addGeoLocationToLocationAutoInMapping(GeoCoordinates geoCoordinates,
Integer id) {
if(this.geoLocationToLocationId == null) {
this.geoLocationToLocationId = new HashMap<String, Integer>();
}
this.geoLocationToLocationId.put(geoCoordinates.toString() +
"_locId", id);
}
得到的是类似的。
这样的工作,但它有点肮脏,我在Solr这样存储一个Java Map,因为我可以得到大量的字段。有没有另一种方法将Java地图写入Solr?
我不想索引它们,我只是想保存数据。
你为什么要这么做?根据您的使用情况,也许最好将地图存储在另一个数据存储区(mongo,couchbase,redis等)中,并在您检索Solr的结果后快速查找。只有保持数据在你真正用于查询的SORL中,并通过这个2站过程检索剩下的数据是一种常见的(我敢说我是最佳实践)模式。 – 2013-03-26 13:24:16