使用HTTP POST时,SOLR查询字符串是否有大小或术语限制? [英] Is there a size or term limit for a SOLR query string when using HTTP POST?

查看:1084
本文介绍了使用HTTP POST时,SOLR查询字符串是否有大小或术语限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java查询SOLR服务器,查找我感兴趣的一组已知ID中的ID的结果。

I'm using Java to query a SOLR server for results that have IDs within a set of known IDs that I am interested in.

我能做的最好的方法我想要获得我感兴趣的这些结果就是创建一个看起来像这样的长查询字符串:

The best way I could think to get just these results that I am interested in was to create a long query string that looks something like this:

q =(item_id: XXX33-3333 OR item_id:YYY42-3445 OR item_id:JFDE-3838)

我生成此字符串, queryString ,在提出请求之前,我最终想要的请求中包含超过1500个这样的ID。我正在使用HTTP POST来进行查询:

I generate this String, queryString, before making my request, and there are over 1500 such ids included in the request I would eventually like to make. I am using an HTTP POST to make the query as such:

        HttpPost post = new HttpPost(url);
        post.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");

        StringEntity entity = new StringEntity(queryString, "UTF-8");
        entity.setContentType("application/x-www-form-urlencoded; charset=utf-8");
        post.setEntity(entity);

        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(post);

如果我将查询限制为前1000个ID,它会成功,我会将结果恢复为我期待。但是,如果我将查询增加到包含我真正感兴趣的所有1500,我会得到一个HTTP 400响应代码,其中包含以下错误:

If I limit the query to just the first 1000 ids, it succeeds and I get the results back as I would expect. However, if I increase the query to include all 1500 that I am really interested in, I get an HTTP 400 response code with the following error:

HTTP / 1.1 400 org.apache.lucene.queryParser.ParseException:无法解析'[我的查询在这里...]

有吗在SOLR查询中我可以和OR一起限制的数量?当我超过1000时,还有另一个原因可能会失败吗?我已经进行了实验,它在1024左右失败(我的ID几乎都是相同的长度)所以它似乎暗示有一个字符或术语限制。

Is there a limit to the number of ids that I can OR together in a SOLR query? Is there another reason this might be failing when I go past 1000? I have experimented and it fails at around 1024 (my ids are all almost the same length) so it seems to suggest there is a character or term limit.

或者,如果有人有一个很好的建议,我可以用另一种更智能的方式检索我正在寻找的物品,我很乐意听到它。我的备份解决方案只是查询SOLR以获取所有项目,解析结果,并使用属于我感兴趣的集合的那些。我宁愿不这样做,因为数据源可以有数以万计的项目,效率低下。

Or, if someone has a good suggestion of how I can retrieve the items I'm looking for in another, smarter, way, I would love to hear it. My backup solution is just to query SOLR for all items, parse the results, and use the ones that belong to the set I am interested in. I would prefer not to do this, since the data source could have tens of thousands of items, and it would be inefficient.

推荐答案

Solr方面没有限制 - 我们经常使用Solr以类似的方式在查询中包含数万个ID。

There is no limit on the Solr side - we regularly use Solr in a similar way with tens of thousands of IDs in the query.

您需要查看servlet容器(Tomcat,Jetty等)的设置并增加最大POST大小。如果您使用的是Tomcat,请查找 maxPostSize ;如果您使用的是Jetty,请查找 maxFormContentSize

You need to look at the settings for your servlet container (Tomcat, Jetty etc.) and increase the maximum POST size. Look up maxPostSize if you are using Tomcat and maxFormContentSize if you are using Jetty.

这篇关于使用HTTP POST时,SOLR查询字符串是否有大小或术语限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆