android - 如何更新 algolia 指数中的新字段
问题描述
如何在现有的 algolia 索引数组中添加新字段值。我在下图中为 ex 创建了一个新索引
使用此链接中的此方法https://stackoverflow.com/a/49607796/4232013
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,但对我来说不清楚,任何人都可以帮助我。谢谢
解决方案
根据官方文档,您可以 partialUpdateObject
index.partialUpdateObjectAsync(
new JSONObject("{\"state\": \"California\"}"),
"myID",//here provide the object Id
null
);
推荐阅读
- html - SVG 不需要的填充
- julia - 用 put!() 切换produce()
- regex - SAS 中的 Prxmatch - 使用 $ 来限制结果不起作用
- python - 熊猫df中的Python多列匹配然后删除不匹配的行
- jquery-ui - 如何在 C# 应用程序中制作徽标设计器?
- javascript - 如何在 angular.json 的脚本部分使用 glob 模式?
- mysql - 将excel数据导入SQL数据库?
- swiftui - SwiftUI:添加元素时选择器内容未刷新
- amazon-web-services - 防止 DynamoDB 流触发 lambda 函数
- vue.js - 如何获取组件数据?如何从外部访问组件?