toptal / chewy

High-level Elasticsearch Ruby framework based on the official elasticsearch-ruby client
MIT License
1.88k stars 366 forks source link

Cleanup journal throws `Yajl::EncodeError: Max nesting depth of 256 exceeded` #878

Open raff-s opened 1 year ago

raff-s commented 1 year ago

Expected behavior

We should be able to use the journal clean functionality even when there are many indices

Actual behavior

It throws Yajl::EncodeError: Max nesting depth of 256 exceeded

Steps to reproduce the problem

Run Chewy::RakeHelper.journal_clean(except:"some_index") You will see that you get a deeply nested ES query that looks like the following

:body=>{:query=>{:bool=>{:filter=>{:bool=>{:should=>[{:bool=>... {:term=>{:index_name=>...

Due to the logic here we'll add one level of nesting per index so when we have a large collection of indices it throws Yajl::EncodeError: Max nesting depth of 256 exceeded

Version Information