ElasticSearch query size limit? - elasticsearch

Does ElasticSearch have a size limit on its JSON queries?
e.g. If I filter using ids, and I build up a list of 1 million+ ids, will the request be rejected?
In theory there must be a ceiling. But I can't find any documentation on it.

indices.query.bool.max_clause_count (Static, integer) Maximum number
of clauses a Lucene BooleanQuery can contain. Defaults to 1024
Refer to this official documentation, to know more about this setting
Add the following configuration in the elasticsearch.yml file to increase the maximum number of clauses.
indices.query.bool.max_clause_count:4096

Related

Elastic Search Version 7.17 Java Rest API returns incorrect totalElements and total pages using queryBuilder

We are currently upgrading our system from ElasticSearch 6.8.8 to ElasticSearch 7.17. When we run pageable queries using the Java Rest API, the results are incorrect.
For example, in version 6.8.8, if we query for data with and request page 2 with a page size of 10, the query return the 10 items on page 2 and give us a totalElement of 10000 records which is correct. When we run this same exact query on Version 7.17, it returns 10 items on page 2 but only gives us a totalElement of 10 instead of the correct number. We need the correct number, so that our gridview handles paging correctly. Is there a setting I am missing in ElasticSearch version 7.17?
Elasticsearch implemented an option of Track_total_hits in all search in ES 7.X.
Generally the total hit count can’t be computed accurately without visiting all matches, which is costly for queries that match lots of documents. The track_total_hits parameter allows you to control how the total number of hits should be tracked. Given that it is often enough to have a lower bound of the number of hits, such as "there are at least 10000 hits", the default is set to 10,000. This means that requests will count the total hit accurately up to 10,000 hits. It is a good trade-off to speed up searches if you don’t need the accurate number of hits after a certain threshold.
So to force ES to calculate all the hit documents you should set Track_total_hits to true. For more information, you can check the ES official documentation page here.

Kibana showing too many buckets exception. How to increase the buckets or is there a better way to handle this?

What is the exact use of bucket size in Kibana ?
[esaggs] > Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"too_many_buckets_exception","reason":"Trying to create too many buckets. Must be less than or equal to: [10000] but was [10001]. This limit can be set by changing the [search.max_buckets] cluster level
I am getting this error, I am dealing with 10000+ documents, do I need to expand the bucket size ?
Currently I am using the bucket size as default.
As mentioned in the ES official documentation,
search.max_buckets (Dynamic, integer) Maximum number of aggregation
buckets allowed in a single response. Defaults to 10000.
Requests that attempt to return more than this limit will return an
error.
max_buckets setting is available at the cluster level settings, you can change it using the below command (but it may adversely affect your cluster)
PUT _cluster/settings
{
"transient": {
"search.max_buckets": 20000
}
}
Refer to this discuss post, to know more about this.

max query length allowed in elasticsearch

I need to send a large bunch of ids in terms query, and i tried with approx 2000 guids, but I found that the data is not being posted to elasticseach. Json array was empty. Is there any limit to max count of values in terms query??and is there any config setting that can increase the max query length for terms query.
I just tried to find out on web if its the json_encode function that does not support such a large array size to encode, but its not the case, so second thing that came to my mind is if elasticsearch terms query supports this or not??
Any help or guidance will be highly appreciated.
If you are using a bool filter or query, it looks like there is a limit of 1024 clauses. See this.
https://groups.google.com/forum/#!topic/elasticsearch/LqywKHKWbeI
Based on that same link, it also appears that you can the option in your elasticsearch.yml

Retrieve all facets for RavenDB query when facets for a given key are over 1024

When I apply the 'ToFacets("facets/CameraFacets")' extension on the 'IQueryable' that comes from my query, I find the count on one of the 'IEnumerable' collections against a facet in the dictionary is 1024. I know for sure there are more, but how do I retrieve them? Will increasing the safe limit automatically give me all values, also is there another way of doing this without having to increase that limit?
Yes if you change the safe limit it will pull in more facets, take a look at the HandleTermsFacet(..) in the code.
However, I wouldn't recommend it. It's a perf issue because 1024 facets means you are doing 1024 seperate queries.
If you need to deal with this many facets, you are better off using a Map/Reduce index, also see this blog post

Get all the results from solr without 10 as limit

How to get all the rows returned from the solr instead of getting only 10 rows?
You can define how many rows you want (see Pagination in SolrNet), but you can't get all documents. Solr is not a database. It doesn't make much sense to get all documents in Solr, if you feel you need it you might be using the wrong tool for the job.
This is also explained in detail in the Solr FAQ.
As per Solr Wiki,
About the row that query returns,
The default value is "10", which is used if the parameter is not specified. If you want to tell Solr to return all possible results from the query without an upper bound, specify rows to be 10000000 or some other ridiculously large value that is higher than the possible number of rows that are expected.
refer this https://wiki.apache.org/solr/CommonQueryParameters
You can setup rows=x, where x is the desired number of doc in the query url.
You can also get groups of 10 doc, by looping over the founds docs by changing start value and leaving row=10
Technically it is possible to get all results from a SOLR search. All you need to do is to specify the limit as -1.

Resources