So far, synonyms appear to be quite straightforward. Unfortunately, this is
where things start to go wrong. For phrase queries to
function correctly, Elasticsearch needs to know the position that each term
occupies in the original text. Multiword synonyms can play havoc with term
positions, especially when the injected synonyms are of differing lengths.

To demonstrate, we’ll create a synonym token filter that uses this rule:

And repeating the validate-query request that we made previously yields a simple,
sane explanation:

"usa is wealthy"

The downside of this approach is that, by reducing united states of america
down to the single term usa, you can’t use the same field to find just the
word united or states. You would need to use a separate field with a
different analysis chain for that purpose.

We have tried to avoid discussing the query_string query because we don’t
recommend using it. In "More-Complicated Queries", we said that, because the
query_string query supports a terse mini search-syntax, it could
frequently lead to surprising results or even syntax errors.

One of the gotchas of this query involves multiword synonyms. To
support its search-syntax, it has to parse the query string to recognize
special operators like AND, OR, +, -, field:, and so forth. (See the full
query_string syntax
for more information.)

As part of this parsing process, it breaks up the query string on whitespace,
and passes each word that it finds to the relevant analyzer separately. This
means that your synonym analyzer will never receive a multiword synonym.
Instead of seeing United States as a single string, the analyzer will
receive United and States separately.

Fortunately, the trustworthy match query supports no such syntax, and
multiword synonyms will be passed to the analyzer in their entirety.