Resolve “application/x-www-form-urlencoded content length (X bytes) exceeds upload limit of 2048 KB” issue in Solr

Resolve "application/x-www-form-urlencoded content length (X bytes) exceeds upload limit of 2048 KB" issue in Solr

“application/x-www-form-urlencoded content length (X bytes) exceeds upload limit of 2048 KB” error occurs when “formdataUploadLimit” reaches its max limit. This means when the Solr tries to fetch more data from the collection and the request content length reaches its maximum limit.

The default value for “formdataUploadLimit” is 2 MB (2048 KB) 

Symptoms

When extracting data using Solr query it will result in an empty dataset, This usually happens when the Solr query return row count is higher 

In this scenario, you will see the below ERROR message in the logs

org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Expected mime type application/octet-stream but got application/xml. <?xml version=”1.0″ encoding=”UTF-8″?>

<response>

<lst name=”error”><str name=”msg”>application/x-www-form-urlencoded content length (13768755 bytes) exceeds upload limit of 13388 KB</str><int name=”code”>400</int></lst>

</response>

at org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:512)

at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)

at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)

at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:91)

at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:310)

Resolution

To resolve the issue, We can increase the max limit to a higher value.

In my case it is 13768755 bytes => 13.768755 MB, So, I have increased it to 50 MB, It can be done by increasing the limit in solrconfig.xml file

Steps to increase the value in the solrconfig.xml

– Download the latest solrconfig.xml file for the collection using the below solrctl command

solrctl instancedir --get <collection_name> <temp path>

– Edit the solrconfig.xml 

vi <temp path>/conf/solrconfig.xml

– Increase the value for the attribute => formdataUploadLimitInKB limit to a higher value of 50 MB in the solrconfig.xml

<requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048000" formdataUploadLimitInKB="50000"

– Upload the new configuration by running the following command on the host:

# solrctl --jaas $SOLR_PROCESS_DIR/jaas.conf instancedir --update collection_name <temp path>

– Reload the collection to make sure the changes are affected

# solrctl collection --reload collection_nam

Alternate Approach

Alternatively, We can set the row limit to a smaller value in the Solr query, If you do not require to get all the rows, we can limit the number of rows that are getting returned

Conclusion

Based on your use case, We can either choose to increase the max limit or to reduce the number of rows that are getting returned from the Solr query.

Good Luck with your Learning !!

Similar Posts