1

假设我们有以下索引结构:

    <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 代码中为索引添加值?

4

1 回答 1

2

由于您想从 Java 代码执行此操作,您可能会考虑查看SolrJ,即 Solr Java 客户端。或者,如果您只想传递纯 http 请求而不使用 SolrJ 客户端,则可以传递多种格式的 http 请求正文。以下是用于发送 XML 或 JSON 的链接

于 2013-09-30T00:52:22.297 回答