Solr 更新哪个更快 solrj 或 curl

Solr Updates which is faster solrj or curl

我有一个案例,我有一组字段要在 solr 中更新。我收到的输入是地图形式,键是字段名称,值是更新后的值。 我怀疑在这种情况下我应该使用 curl 来更新 doc 还是 solrj 我必须将地图转换为 solrInputDocument 然后调用 add 命令。第一种方法会比第二种方法快吗?

  • 您可以将地图转换为 SolrInputdocument。

  • Curl 使用 HTTP URL。所有请求都转到 HttpSolrServer(我不太确定)。 但是,根据我的经验,我强烈建议 ConcurrentUpdateSolrServer 用于更新

SolrJ 有 ConcurrentUpdateSolrServer class,如下所述。

ConcurrentUpdateSolrServer buffers all added documents and writes them into open HTTP connections. This class is thread safe. Params from UpdateRequest are converted to http request parameters. When params change between UpdateRequests a new HTTP request is started. Although any SolrServer request can be made with this implementation, it is only recommended to use ConcurrentUpdateSolrServer with /update requests. The class HttpSolrServer is better suited for the query interface.

以下是获取 Solr Server 实例的示例方法

/**
     * Method lookUpConcurrentUpdateSolrServerInstance.
     * 
     * @param baseURL String
     * @param collection String
     * @return ConcurrentUpdateSolrServer
     * @throws SolrServerException
     * @throws IOException
     * @throws Exception
     */
    public static ConcurrentUpdateSolrClient lookUpConcurrentUpdateSolrServerInstance(String baseURL, String collection)
                    throws SolrServerException, IOException, Exception {

        ConcurrentUpdateSolrClient solrServer = null;
        if (StringUtils.isNotBlank(baseURL) && StringUtils.isNotBlank(collection)) {

            solrServer = new ConcurrentUpdateSolrClient(baseURL + collection, "queueSizeasInteger", 10), 
                            "threadCount as integer", 10));
            checkServerStatus(solrServer);
            return solrServer;
        }

        return solrServer;
    }