开发者

Adding non-string fields with SolrJ

I have a class called Dataset that has an Organization field. I want to add this to the solr index. I gave to Organization's fields proper annotation as well.

public class Dataset {

    @Field("publisher")
    @rdf("http://www.w3.org/ns/foaf#publisher")
    private Organization pu开发者_运维问答blisher;

public class Organization  {

    @Field("OrganizationName")
    @rdf("http://www.w3.org/ns/foaf#name")
    private String name;

But when I add the bean to solr what I get is something like this:

<doc>
<arr name="keyword">
<str>public</str>
</arr>
...
<date name="modified">1995-12-31T23:59:59Z</date>
<str name="publisher">Organization [name=MECON]</str>
...
<str name="type">dataset</str>
</doc>

I don't really like how it looks and is ugly to get facets from that. I would like to get something like an individual field called publisherName or something like that (one string for each field in Organization class). Do i need to define a fieldType to the publisher field? How can resolve this issue? Is there any example?


As far as I know, SolrJ doesn't support nested objects yet. See the corresponding JIRA issue about it to get updates and/or contribute to implementing it.

In the meantime, it's up to you to flatten your object graph.


The issue is fixed now, how ever it's difficult to figure out how to use document object binding in general, so I requested an update of the solj tutorial at https://issues.apache.org/jira/browse/SOLR-11032 and will update this answer as soon as it's fixed.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜