2016-09-28 12 views
0

この質問はBeanとしてのSolrJ文書に関連しています。私はそこに別のエンティティを持っているエンティティ を持っています。内部エンティティに の注釈を付ける方法を教えてください。私が直面している問題は、内部エンティティフィールドがインデックス作成中に見つからない です。下の例では、コンテンツ のフィールドを追加し、著者名とIDを紛失しています。SolrJ POJO注釈

例:「Content」は、has-a 関係エンティティとして「Author」を持つ1つのクラスです。

class Content{ 

@Field("uniqueId") 
String id; 

@Field("timeStamp") 
Long timeStamp; 

//What should be the annotation type for this entity? 
Author author; 
} 

class Author{ 
@Field("authorName") 
String authorName; 

@Field("authorId") 
String id; 

} 

マイスキーマのXMLは次のとおりです。

<field name="uniqueId" type="string" /> 
<field name="timeStamp" type="long" /> 
<field name="authorName" type="string" /> 
<field name="authorId" type="string" /> 

答えて

0

SOLR-1945これによると、あなたがJava docsで見ることができるよう、@Field注釈にchildプロパティを使用することにより、Solrの5.1ので、可能です。あなたのケースでは

それは次のようになります。

class Content { 
    @Field("uniqueId") 
    String id; 

    @Field("timeStamp") 
    Long timeStamp; 

    @Field(child = true) // You should use this annotation 
    Author author; 
} 



class Author { 
    @Field("authorName") 
    String authorName; 

    @Field("authorId") 
    String id; 
}