所以我有一个 elasticsearch 数据库,我用来存储联系人。我做下面的查询。
public String getAllContacts() throws IOException {
SearchResponse response = client.prepareSearch("contact").get();
return response.toString();
}
Run Code Online (Sandbox Code Playgroud)
然后我想将 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)