Solrj (1.4.1) 性能相关查询
我在我的项目中使用 Solrj 作为 Solr 客户端。
在搜索几个单词时,Solrj 似乎需要更多时间来发送响应,例如(8 - 12 秒)。在搜索大多数其他单词时,Solrj 似乎只花费了更少的时间。
例如,如果我在浏览器中发布搜索网址,它只会显示 QTime(以毫秒为单位)。
http://serverName/solr/mydata/select?q =computing&qt=myhandler&fq=category:1
但是,如果我使用 Solrj 从我的项目中查询相同的结果,如下所示,则需要很长时间(8 - 12 秒)才能产生相同的结果。因此,我怀疑Solrj是否需要这么长时间才能产生结果。
SolrServer 服务器 = new CommonsHttpSolrServer(url); SolrQuery 查询 = new SolrQuery("计算"); query.setParam("qt", "myhandler"); query.setFilterQueries("类别:1"); 查询.setHighlight(假); QueryResponse rsp = server.query( 查询 );
POTH 和 GET 方法我都试过了。但是,两者都需要很多时间。
知道为什么 Solrj 花这么长时间来处理特定的单词吗?它返回大约 40 个文档列表作为搜索结果。我什至对此进行了评论并强调。
以及任何加快速度的方法。
注意:我使用 Tomcat 并将堆大小设置为 1024 mb 左右。我使用的是 Solr 1.4.1 版本。
谢谢,
I am using Solrj as a Solr client in my project.
While searching, for a few words, it seems Solrj takes more time to send response, for eg (8 - 12 sec). While searching most of the other words it seems Solrj take less amount of time only.
For eg, if I post a search url in browser, it shows the QTime in milliseconds only.
http://serverName/solr/mydata/select?q=computing&qt=myhandler&fq=category:1
But, if I query the same using Solrj from my project like below, it takes long time(8 - 12 sec) to produce the same results. Hence, I suspect whether Solrj takes such long time to produce results.
SolrServer server = new CommonsHttpSolrServer(url);
SolrQuery query = new SolrQuery("computing");
query.setParam("qt", "myhandler");
query.setFilterQueries("category:1");
query.setHighlight(false);
QueryResponse rsp = server.query( query );
I have tried both POTH and GET method. But, both are taking much time.
Any idea why Solrj takes such long time for particular words. It returns around 40 doc list as a search result. I have even comment out highlighting for that.
And any way to speed it up.
Note: I am using Tomcat and set heap size as around 1024 mb. And I am using Solr 1.4.1 version.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与直接访问 Solr 相比,SolrJ 不会产生很大的性能影响。我正在使用它,Solr 中耗时 2-3 毫秒的查询将在大约 12-15 毫秒内通过网络返回,包括遍历完整的 Web 堆栈并编组到 Json。我怀疑您的代码中其他地方有错误。尝试获取配置文件或散布一些打印语句以查看时间浪费在哪里。如果您要穿越网络(我怀疑您是),请尝试执行 ping 操作以查看响应时间。您还可以尝试从源服务器到 Solr 服务器的curl 请求,以查看原始响应时间是多少
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
我能够调整 PHP 以获得与 Java 的 SolrJ 相同的性能。然而,这是大量的工作,而且还没有完全证明。 PHP 最大的问题不是速度而是内存泄漏。当您索引数千条记录时,您必须循环遍历它们,这会在 PHP 中产生内存泄漏。我通过使用 bash 脚本在 PHP 中调用较小的批处理来划分 PHP 批处理过程。但我仍然会索引失败。 Java的SolrJ解决了内存泄漏问题并提供了更好的可靠性。 Java 速度很快,无需像我使用 bash 脚本和 PHP 那样通过创造性的障碍来获得速度。
另外,不要在 SolrJ 中提交您的记录。在 solr 的配置上打开自动提交并允许 Solr 处理提交。快得多。
I was able to tweak PHP to get on par performance with Java's SolrJ. However, it was a lot of work and not full proof. The biggest problem with PHP is not speed but memory leaks. When you index thousands of records, you have to loop through them and that produces memory leaks in PHP. I divided the PHP batch process up by using bash scripts to call smaller batches in PHP. But I would still get failed indexing. Java's SolrJ solves the memory leak problems and offers better reliability. Java is fast without having to jump through creative hoops to get speed like I had to do with bash scripts and PHP.
Also, don't commit your records in SolrJ. Turn on auto commit on solr's config and allow Solr to handle committing. So much faster.