我是 flex 搜索的新手,我想使用应用程序中的jest API终止在 flex 搜索中索引的文档。我发现有一个称为TTL的参数。但是我在从 Jest 的客户端将参数设置为enabled和true时面临问题。请让我知道如何完成此操作。
提前致谢!
最佳答案
这似乎对我有用:
final String index = "myindex";
final String type = "mytype";
final String id = "myid";
final PutMapping putMapping = new PutMapping.Builder(index, type, "{ \"_ttl\" : { \"enabled\" : true } }").build();
client.execute(putMapping);
final Map<String, String> documentToIndex = new HashMap<String, String>();
documentToIndex.put("name", "Fred");
documentToIndex.put("phoneNumber", "1234");
documentToIndex.put("_ttl", "30s"); // Set the TTL
final String jsonDocument = gson.toJson(documentToIndex);
final JestResult result = client.execute(new Index.Builder(jsonDocument).index(index).type(type).id(id).build());
关于elasticsearch - 如何使用java应用程序中的jest api使文档在 Elasticsearch 中过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36889940/