如何更新 algolia Indices 中的新字段
How to update a new field in algolia Indices
如何在现有的 algolia 索引数组中添加新的字段值。我在下图中为 ex 创建了一个新索引
使用此 link
中的方法
user_details.put("user_username", username);
user_details.put("user_email_id", email);
user_details.put("user_id", UUID);
Client client = new Client(ApplicationId, AlgoliaKey);
Index index = client.getIndex("Users");
List<JSONObject> array = new ArrayList<JSONObject>();
array.add(new JSONObject(user_details));
index.addObjectsAsync(new JSONArray(array), null);
但稍后如果我想添加图像 url 我如何更新现有索引中的这个字段
我查看了官方文档 https://www.algolia.com/doc/api-reference/api-methods/partial-update-objects/#examples 但我不太清楚 谁能帮我 out.Thanks
根据官方文档,您可以使用 partialUpdateObject
index.partialUpdateObjectAsync(
new JSONObject("{\"state\": \"California\"}"),
"myID",//here provide the object Id
null
);
如何在现有的 algolia 索引数组中添加新的字段值。我在下图中为 ex 创建了一个新索引
使用此 link
user_details.put("user_username", username);
user_details.put("user_email_id", email);
user_details.put("user_id", UUID);
Client client = new Client(ApplicationId, AlgoliaKey);
Index index = client.getIndex("Users");
List<JSONObject> array = new ArrayList<JSONObject>();
array.add(new JSONObject(user_details));
index.addObjectsAsync(new JSONArray(array), null);
但稍后如果我想添加图像 url 我如何更新现有索引中的这个字段 我查看了官方文档 https://www.algolia.com/doc/api-reference/api-methods/partial-update-objects/#examples 但我不太清楚 谁能帮我 out.Thanks
根据官方文档,您可以使用 partialUpdateObject
index.partialUpdateObjectAsync(
new JSONObject("{\"state\": \"California\"}"),
"myID",//here provide the object Id
null
);