您可以使用POST在Solr中运行查询吗(/选择) [英] Can you use POST to run a query in Solr (/select)

查看:41
本文介绍了您可以使用POST在Solr中运行查询吗(/选择)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些针对solr索引的查询,这些查询有时具有很长的查询参数,运行这些查询时会出错,我认为这是在GET查询参数的限制范围内完成的.

I have queries that I am running against out solr index that sometimes have very long query parameters, I get errors when i run these queries, which i assume are do to the limit of a GET query parameters.

这是我用来查询(JSON)的方法,这表明我正在使用Http扩展(我使用的客户端是HttpClient的瘦包装器),而不是端对端解决方案.90%的查询运行良好,这只是当参数很大时,我从solr中得到了500错误.我读过某处可以在执行select命令时使用POSt的地方,但尚未找到如何执行此操作的示例.任何帮助都太棒了!

Here is the method I use to query (JSON), this is to show I am using the Http Extensions (the client i use is a thin wrapper for HttpClient) not an end to end solution. 90% of the queries run fine, it is just when the params are large i get the 500 error from solr. I have read somewhere you can use POSt's when doing the select command but have not found examples of how to do it. Any help would be fantastic!

    public string GetJson(HttpQueryString qs)
    {
        using (var client = new DAC.US.Web.XmlHttpServiceClient(this.Uri))
        {
            client.Client.DefaultHeaders.Authorization = new Microsoft.Http.Headers.Credential("Basic", DAC.US.Encryption.Hash.WebServiceCredintials);
            qs.Add("wt", "json");

            if (!String.IsNullOrEmpty(this.Version))
                qs.Add("version", this.Version);

            using (var response = client.Get(new Uri(@"select/", UriKind.Relative), qs))
            {
                return response.Content.ReadAsString();
            }
        }
    }

推荐答案

  1. 不要假设.检查Solr日志以确认此错误的原因.
  2. /select接受POST请求而没有问题.您可以使用curl尝试此操作:

  1. Don't assume. Check the Solr log to confirm the reason of this error.
  2. /select accepts POST requests without issues. You can try this with curl:

curl -d "q=*:*&rows=1" http://localhost:8983/solr/select

我无法评论XmlHttpServiceClient,因为它似乎是一些专有代码,但是请参见此页面有关使用HttpWebRequest进行POST的示例.

I can't comment on XmlHttpServiceClient as it seems to be some proprietary code, but see this page for an example of POSTing using HttpWebRequest.

顺便说一句:有些.net库实现了与Solr的通信,除非您有一些非常奇怪的要求,否则无需自己动手.

BTW: there are .net libraries that implement communicating with Solr, no need to roll your own unless you have some very weird requirements.

这篇关于您可以使用POST在Solr中运行查询吗(/选择)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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