【问题标题】:Solr bean fields not workingSolr bean 字段不工作
【发布时间】:2016-05-13 22:20:41
【问题描述】:

我有一个名为 Node 的类,我想使用 Solr Beans 功能将所有 Node 对象数据发送到 solr。

我已经在 schema.xml 中定义了所有字段,但是有一个(字段 description)没有在 solr 中被索引,我不明白为什么。 p>

我的班级(模型):

import com.avaje.ebean.Model;
import org.apache.solr.client.solrj.beans.Field;
public class Node extends Model {
    @Id
    @Field("id)
    public long id;

    @Constraints.Required
    @Field("code")
    public String code;

    @Field("name")
    public String name;

    @Lob //support big strings (bigger than varchar(255) in db
    @Field("description")
    public String description;
}

索引节点对象:

SolrClient solrClient = new HttpSolrClient(url);
solrClient.addBeans(Node.find.all());
solrClient.commit(); //try catchs ...

我在 schema.xml 中的字段

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />   
<field name="_version_" type="long" indexed="true" stored="false"/>
<field name="antecessorNodeCode" type="text_pt" indexed="false" stored="true" multiValued="false"/>
<field name="code" type="text_pt" indexed="true" stored="true" multiValued="false"/>
<field name="name" type="text_pt" indexed="true" stored="true" multiValued="false"/>
<field name="description" type="text_pt" indexed="true" stored="true" multiValued="false"/>
<field name="includeEvents" type="text_pt" indexed="true" stored="true" multiValued="true"/>
<field name="excludeEvents" type="text_pt" indexed="true" stored="true" multiValued="true"/>

有人可以检测到这里的错误吗?

【问题讨论】:

  • 为清楚起见,请为其他注释添加导入。

标签: java solr javabeans solrj


【解决方案1】:

我注意到失败, 我试图在带有type="text_pt 的字段中保存一个BLOB (@Lob),它们是不同的类型。 因此,或者我创建一个支持 blob(二进制)的字段,或者我可以在 db @Column(length = 750) 中接受更大的字符串并保持相同的字段类型。

【讨论】:

    猜你喜欢
    • 2012-08-11
    • 2011-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多