简体   繁体   English

如何使用 JEST 客户端在弹性搜索中添加自定义名称?

[英]How to add custom name in elastic search using JEST client?

How to add custom name to elastic search using JEST client?如何使用 JEST 客户端向弹性搜索添加自定义名称?

For Example Using Spring data You can use custom name.例如使用 Spring 数据您可以使用自定义名称。 Spring Data ES use Jackson. Spring Data ES 使用 Jackson。 So, you can use @JsonProperty("your_custom_name") to enable custom name in ES Mapping因此,您可以使用@JsonProperty("your_custom_name")在 ES Mapping 中启用自定义名称

With jest client for elasticsearch, you need not specify any annotations for the field names.使用elasticsearch 的jest 客户端,您无需为字段名称指定任何注释 The variable name itself is used by jest client to write data into elasticsearch. jest 客户端使用变量名称本身将数据写入 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、author 和 pages 的文档。

{
   "documentId" : "doc_01",
   "author" : "John Doe",
   "pages" : 3
}

Jest client is using Gson for serialisation. Jest 客户端使用Gson进行序列化。 So, you can use the @SerializedName annotation for custom name.因此,您可以使用 @SerializedName 注释作为自定义名称。 Eg.例如。

class Article {

  @JestId
  private String documentId;

  @SerializedName("author_name")
  private String authorName;

  @SerializedName("page_s")
  private int pages;

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java客户端更新Elastic Search上的条目 - How to update an entry on Elastic Search using Java client 如何在java中使用jest客户端在elasticsearch中编写搜索代码 - how to write code for search in elasticsearch using jest client in java 弹性搜索客户端使用R包 - elastic search client using R packages 如何通过 Java 高级 rest 客户端在 Elastic Search 中使用多个字段进行搜索 - How to search using multiple fields in Elastic Search through Java high level rest client 如何向 Elastic Transport Client 添加身份验证 - How to add authentication to Elastic Transport Client 使用弹性搜索Java客户端时,如何上传pdf到elasticsearch? - How do I upload a pdf to elasticsearch when using the elastic search java client? 弹性搜索 如果使用低级 Rest Client 对特定数据库列进行了任何更改,如何检索数据 - Elastic Search How to retrieve the data if any changes made to a particular database column using Low Level Rest Client 使用java在弹性搜索中创建自定义停用词列表 - Create list of custom stop words in elastic search using java 弹性搜索:使用弹性搜索 API 生成弹性搜索查询 - Elastic Search: Generating Elastic Search query using Elastic search API 弹性搜索错误:自定义分析器[custom_analyzer]找不到名称为[my_tokenizer]的令牌生成器 - Elastic Search error : Custom Analyzer [custom_analyzer] failed to find tokenizer under name [my_tokenizer]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM