0

我在我的项目中使用 Solrj 作为 Solr 客户端。

在搜索时,对于几句话,Solrj 似乎需要更多时间来发送响应,例如(8 - 12 秒)。在搜索大多数其他词时,似乎 Solrj 只需要更少的时间。

例如,如果我在浏览器中发布搜索 url,它仅以毫秒为单位显示 QTime。

http://serverName/solr/mydata/select?q=computing&qt=myhandler&fq=category:1

但是,如果我在下面的项目中使用 Solrj 查询相同的内容,则需要很长时间(8 - 12 秒)才能产生相同的结果。因此,我怀疑 Solrj 是否需要这么长时间才能产生结果。

SolrServer 服务器 = 新 CommonsHttpSolrServer(url); SolrQuery 查询 = new SolrQuery("计算"); query.setParam("qt", "myhandler"); query.setFilterQueries("category:1"); query.setHighlight(false); QueryResponse rsp = server.query(query);

我已经尝试过 POTH 和 GET 方法。但是,两者都需要很多时间。

知道为什么 Solrj 需要这么长时间来处理特定的单词。它返回大约 40 个文档列表作为搜索结果。我什至对此进行了注释。

以及任何加快速度的方法。

注意:我使用的是 Tomcat 并将堆大小设置为 1024 mb 左右。我正在使用 Solr 1.4.1 版本。

谢谢,

4

2 回答 2

0

我能够调整 PHP 以获得与 Java 的 SolrJ 相同的性能。然而,这是大量的工作,并没有充分的证据。PHP 最大的问题不是速度而是内存泄漏。当您索引数千条记录时,您必须遍历它们,这会在 PHP 中产生内存泄漏。我通过使用 bash 脚本在 PHP 中调用较小的批处理来划分 PHP 批处理。但是我仍然会失败索引。Java 的 SolrJ 解决了内存泄漏问题并提供了更好的可靠性。Java 速度很快,而无需像我使用 bash 脚本和 PHP 那样跳过创造性的圈子来获得速度。

另外,不要在 SolrJ 中提交您的记录。在 solr 的配置上打开自动提交并允许 Solr 处理提交。这么快。

于 2012-09-25T01:25:27.480 回答
0

SolrJ does not give a large performance impact over hitting Solr directly. I'm using it, and queries taking 2-3ms within Solr are being returned over the network in around 12-15ms, including going through a full web stack and marshalling to Json. I suspect there's an error elsewhere in your code. Try getting a profile or sprinkling some print statements to see where the time is being lost. If you're going across the network (I suspect you are), try doing a ping to see what the response times are. You could also try a curl request from your source server to your Solr server to see what the raw response times are

于 2011-03-30T19:29:14.127 回答