我想知道如何同時使用兩個不同的分析器分析彈性搜索欄位。我正在創建一個 elasticsearch 插件,所以我需要 java 代碼來實作它。
uj5u.com熱心網友回復:
您可以在 java 代碼中使用Create Index API來創建具有多欄位的索引
CreateIndexRequest request = new CreateIndexRequest("twitter");
Map<String, Object> email_second = new HashMap<>();
email_second.put("type", "text");
email_second.put("analyzer", "custom_standard");
Map<String, Object> email = new HashMap<>();
email.put("type", "text");
email.put("analyzer", "standard");
email.put("fields", "email_second");
Map<String, Object> properties = new HashMap<>();
properties.put("email", email);
Map<String, Object> mapping = new HashMap<>();
mapping.put("properties", properties);
request.mapping(mapping);
CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT);
您可以使用名稱訪問第一個電子郵件欄位,email然后使用email.email_second名稱訪問第二個電子郵件欄位。
uj5u.com熱心網友回復:
您可以使用多欄位來實作相同的目的。請參閱檔案中的多個分析器部分并舉例說明。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/444324.html
