简体   繁体   English

如果添加大量过滤器查询,solrnet 会崩溃

[英]solrnet crashes if you add a lot of filter queries

We use solrnet in our ASP.NET Core backend.我们在 ASP.NET 核心后端中使用solrnet In the startup.cs it is initialized like:startup.cs中,它的初始化如下:

public void ConfigureServices(IServiceCollection services)
{
     services.AddSolrNet<SolrPunt>(solrEndpointAddressForPunt, setup =>
     {
           setup.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentialsBase64);                
     });  
}

The search code itself is quite simple.搜索代码本身非常简单。 We inject an instance of ISolrOperations<solrEndpointAddressForPunt> , and use it accordingly:我们注入一个ISolrOperations<solrEndpointAddressForPunt>的实例,并相应地使用它:

var queryOptions = new QueryOptions
{
    FilterQueries = new List<ISolrQuery>()
};

// FilterQueries are added 

var solrResponse = await solrOperationsVoorPunten.QueryAsync("*:*", queryOptions);

This all works fine and we receive results correctly.这一切正常,我们正确收到结果。

However, if we add a lot of filter queries, like more than 105, it throws an exception:但是,如果我们添加很多过滤查询,比如超过 105 个,就会抛出异常:

Data at the root level is invalid.根级别的数据无效。 Line 1, position 1 1号线,position 1

I'm wondering why this is and how this can be fixed.我想知道为什么会这样以及如何解决这个问题。

It has nothing to do with XML/JSON setting, as it works perfectly with a small amount of filter queries.它与 XML/JSON 设置无关,因为它与少量过滤器查询完美配合。

I'm thinking it has to do with the limit of a GET request.我认为这与 GET 请求的限制有关。 But then I read that normally it should then switch to a POST automatically?但是后来我读到它通常应该自动切换到POST? Can I tell solrnet to always use POST?我可以告诉 solrnet 始终使用 POST 吗? And if so, how to do that in ASP.NET core?如果是这样,如何在 ASP.NET 内核中做到这一点?

Or is there another limitation that is causing this?还是有其他限制导致了这种情况?

Thanks for any advice!感谢您的任何建议!

I think I found it.我想我找到了。 Instead of concatenating the fields in a for loop:而不是在 for 循环中连接字段:

solrQueryByField = solrQueryByField || new SolrQueryByField(filterVeld, filterValue);

... I simply use SolrQueryInList : ...我只是使用SolrQueryInList

queryOptions.FilterQueries.Add(new SolrQueryInList(filterVeld, filterValues));

With this change, it started working...随着这个变化,它开始工作......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM