How to add custom name to elastic search using JEST client?
For Example Using Spring data You can use custom name. Spring Data ES use Jackson. So, you can use @JsonProperty("your_custom_name")
to enable custom name in ES Mapping
With jest client for elasticsearch, you need not specify any annotations for the field names. The variable name itself is used by jest client to write data into elasticsearch. For example :
class Article {
@JestId
private String documentId;
private String author;
private int pages;
}
Writing the above class will generate the documents with field names as documentId, author and pages.
{
"documentId" : "doc_01",
"author" : "John Doe",
"pages" : 3
}
Jest client is using Gson for serialisation. So, you can use the @SerializedName annotation for custom name. Eg.
class Article {
@JestId
private String documentId;
@SerializedName("author_name")
private String authorName;
@SerializedName("page_s")
private int pages;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.