我将ElasticSearch用于应用程序以存储和搜索数据。 因为在我的特定情况下搜索关系也很重要,我最近改变了数据的结构,现在我正在使用_parent字段。 (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-parent-field.html)
我已经设计了搜索查询,完全正常。但是,在数据库中插入新的子条目时,我现在遇到了问题。
它应该以这种方式工作:
没有_parent字段,当我想实现这个
时$ curl -XPUT 'http://localhost:9200/data/child/1' -d '
我使用JEST API以这种方式插入数据:
client.execute(new Index.Builder(payload).index("data").type("child").build());
当我想要实现这个目标时:
$ curl -XPOST localhost:9200/data/child?parent=154121-d'
我应该如何使用JEST-API实现这个?
我已经在Google // Stackoverflow上搜索了答案,但没有找到解决方案。
提前谢谢! :)
答案 0 :(得分:13)
我终于找到了解决方案! :)
可以为请求提供参数。实现此目的的正确代码行:
$ curl -XPOST localhost:9200/data/child?parent=154121-d'
将通过以下方式实现:
client.execute(new Index.Builder(payload).index("data").type("child").setParameter("parent", "154121").build());
希望将来有人可以帮助这个答案! :)