开发者

solrj: using a POJO with non-string fields

开发者 https://www.devze.com 2023-02-12 13:02 出处:网络
I\'m brand-new to solr and solrj, and investigating them as a potential platform for a search-oriented app.

I'm brand-new to solr and solrj, and investigating them as a potential platform for a search-oriented app.

We have a lot of da开发者_JS百科ta in a MongoDB instance, with pojos defined in Java. I'd like to migrate the data over to solr using my existing MongoDB POJOs, by adding solrj @Field annotations.

This seems to work fine for String fields, but not so much for ints:

org.apache.solr.common.SolrException: ERRORunknown_field_downloadsCount

Is there a simple way to get solrj to automatically map ints (and potentially other non-string types) to String?

I guess I could just alter my class with something like:

@Field("downloadCount")
String getDownloadCountAsString() { return Integer.toString(downloadCount); }

But I was wondering if there was a more robust solution.


The error suggests that you don't have a 'downloadsCount' field in the Solr schema. Check your schema.xml.

0

精彩评论

暂无评论...
验证码 换一张
取 消