SolrJ只有枚举类型的值

时间:2017-11-23 10:00:19

标签: solr solrj

我尝试使用SolrJ向Solr添加文档。这是我的@Field注释类:

public class Popular {
@Field("popular_id")
private Long popularId;

@Field("type")
private Type type;

public Long getPopularId() {
    return popularId;
}

public void setPopularId(Long popularId) {
    this.popularId = popularId;
}

public Type getType() {
    return type;
}

public void setType(Type type) {
    this.type = type;
}

}

这是我的枚举:

public enum Type {
SERVICE,
BRAND,
CITY
}

这是我使用SolrJ向Solr添加文档的方法:

private void addPopularItem(SolrClient client, Long popularId, String[] wordsArray)
    throws IOException, SolrServerException {

    Popular popular = new Popular();
    popular.setPopularId(popularId);
    popular.setType(Type.valueOf(wordsArray[1]));

    client.addBean(popular);
}

我的文件是Solr看起来像那样:

{
    "popular_id":[1],
    "**type**":["com.XXX.XXX.XXX.indexes.popular.Type:SERVICE"],
    "id":"7306406f-4b99-4cee-9c9a-0b7ee84cd5b9",
    "_version_":1584849462071656448,
    "type_str":["com.XXX.XXX.XXX.indexes.popular.Type:SERVICE"]
}

有没有办法更改该类型字段,因此它只有来自Type enum而不是package + class name + value的值?

0 个答案:

没有答案