小编Din*_*hka的帖子

Elasticsearch Java api 查询 JSON 解析器

所以我有一个 elasticsearch 数据库,我用来存储联系人。我做下面的查询。

 public String getAllContacts() throws IOException {

    SearchResponse response = client.prepareSearch("contact").get();

    return response.toString();
}
Run Code Online (Sandbox Code Playgroud)

所以我从查询中得到了这样的 Json 结果

然后我想将 Json 数据放入我的 Contact 类对象中

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
public class Contact {

    private long id;
    private String name;
    private Date date;

    public Contact() {}
    public Contact(long id, String name, Date date) {
        this.id = id;
        this.name = name;
        this.date = date;
    }
    public long getId() {return id;}
    public void setId(long id) {this.id …
Run Code Online (Sandbox Code Playgroud)

java json elasticsearch

3
推荐指数
1
解决办法
3931
查看次数

标签 统计

elasticsearch ×1

java ×1

json ×1