XFES's getMaxKeywords is not effective depending on the number of fields being searched


Well-known member
Affected version
ElasticSearch exposes a "max clauses" (under a bunch of names) which indicates how many search terms can be used.

XenForo applies this to the search keywords as-is, the trouble is this doesn't capture that simple_query_string decomposes to a number of search clauses based on the fields being searched. ie "max clauses" reports 1024, but XenForo searches "message" and "title" means the max keywords is much lower. Facets search (ie allowed forums, by user list, etc) also count to the "max clauses" count.

And I'm positive how Elasticsearch counts these things varies depending on version.

This is noticeable in one of my addons (ElasticSearch Essentials) which optionally injects ".exact" variants of message/title to allow stop-words/stemming to be used and also exact matches to be preferred.

Maybe the only sane thing is to check's elasticsearch error message for too_many_clauses and if so, reporting the search has too many clauses?
I'm wondering if it is the max clause is being hit because the search string is tripping up parseKeywords because of unicode characters so XF is counting less terms than actually exists in the phase
Top Bottom