我有一个简单的产品类如下所示
@SolrDocument(collection = "product")
public class Product {
@Id
@Indexed(name = "id", type = "string")
private String id;
@Field
@Indexed(name = "namex", type = "text_general", stored = false, searchable=true)
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}我的问题是注释@Indexed被完全忽略了。字段的名称只是名称(而不是namex),并且字段是存储的。有猜到吗?
更新1如果我删除了类型注释名工作,但存储仍然没有效果。
发布于 2018-03-08 12:06:24
我通过修改创建SolrTemplate对象的bean来进行管理,如下所示:
@Bean
public SolrTemplate solrTemplate(SolrClient client) throws Exception {
SolrTemplate st = new SolrTemplate(client);
st.setSchemaCreationFeatures(Collections.singletonList(Feature.CREATE_MISSING_FIELDS));
st.afterPropertiesSet();
return st;
}https://stackoverflow.com/questions/49163889
复制相似问题