advanced-object-search icon indicating copy to clipboard operation
advanced-object-search copied to clipboard

[Bug]: ManyToOneRelation can maximum return 10 hits

Open AndrewKMoses opened this issue 2 years ago • 3 comments

Expected behavior

Filtering using ManyToOneRelation returns all matches

Actual behavior

Filtering using ManyToOneRelation returns maximum 10 hits.

Steps to reproduce

I have a template setup as below where Options is a ManyToOneRelation.

image

On the line below, there is no size parameter included, giving you the default size, which is 10.

https://github.com/pimcore/advanced-object-search/blob/4.x/src/Filter/FieldDefinitionAdapter/ManyToOneRelation.php#L121

I tried setting this to something very large (10000) giving me the error message below:

`{ "error": { "root_cause": [ { "type": "query_shard_exception", "reason": "failed to create query: maxClauseCount is set to 1024", "index_uuid": "8P3R0UYRTHOrMiL0YPZlAg", "index": "advanced_object_search_article" } ], "type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true, "failed_shards": [ { "shard": 0, "index": "advanced_object_search_article", "node": "1lK30pC5RayahBM7mN_duA", "reason": { "type": "query_shard_exception", "reason": "failed to create query: maxClauseCount is set to 1024", "index_uuid": "8P3R0UYRTHOrMiL0YPZlAg", "index": "advanced_object_search_article", "caused_by": { "type": "too_many_clauses", "reason": "maxClauseCount is set to 1024" } } } ] }, "status": 400 }

Server threw exception - could not perform action. Please reload the admin interface and try again.`

There is a setting (indices.query.bool.max_clause_count) to change the maximum number of clauses, but the docs do not recommend that.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-settings.html

AndrewKMoses avatar Sep 09 '22 06:09 AndrewKMoses

@AndrewKMoses Thank you for the report but i cannot reproduce the exact same problems, i can change the maximum $size to 10000 without problems, over that throws errors. image But it's different from your case, it mentions Clause

For me it works, even on demo using the Manufacturer many-to-one field

image image

Can you provide further details?

kingjia90 avatar Sep 13 '22 14:09 kingjia90

Well, my main point in this issue is that the size argument is missing, giving you a default of 10 hits. That should be fixed somehow?

What is indices.query.bool.max_clause_count configured to in your case? That might explain the different results in error.

In your case it seems like it's the same issue as in https://github.com/pimcore/advanced-object-search/issues/85?

AndrewKMoses avatar Sep 13 '22 14:09 AndrewKMoses

Well, my main point in this issue is that the size argument is missing, giving you a default of 10 hits. That should be fixed somehow?

yes, that's a good point and needs to be improved. The question now is what number should replace 10 . One idea that comes to my mind is be to allowing the user to type its own numbers, by adding 2 extra optional fields eg. $from/$size on each filter.

What is indices.query.bool.max_clause_count configured to in your case? That might explain the different results in error.

I haven't changed any configuration, so it should be also the same default value at 1024. NB: Since v8, they changed default value to 4096.

In your case it seems like it's the same issue as in #85?

Doesn't look the same to me, i've just put a $size value that exceeded index.max_result_window. The actual response is not that large to crash.

kingjia90 avatar Sep 13 '22 20:09 kingjia90