假设我们有以下索引结构:
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="user" type="string" indexed="true" stored="true"/>
我们想为此索引添加一个值。在cookbook4中,这是通过这样的命令完成的
curl'localhost:8983 / solr / update?commit = true'-H'Contenttype: application / json'-d'[{“id”:“1”,“user”:{“add”:“jack”}}]'
如何通过传递http请求从java代码中为索引添加值?
答案 0 :(得分:2)
由于您希望从Java代码执行此操作,因此您可以考虑查看SolrJ Solr Java客户端。或者,如果您只想传递纯http请求而不使用SolrJ客户端,则可以以多种格式传递http请求正文。以下是用于发送XML或JSON的链接