The reason your query doesn't work is because of how CloudSearch stems. If your field is indexed with the Analysis Scheme set to English
, then wars
will be stored in its stemmed form as war
.
Here's a little demo of how stemming is affecting your query.
Searching with the un-stemmed query ('ster wers'):
Searching with the un-stemmed query requires you to match wers
to war
, which is off by 2 chars and requires this query: q=ster~1+wers~2
.
Searching with the stemmed query ('ster wer'):
Searching with the stemmed version means you're matching wer
to war
and you're only off by 1 char. Thus ster~1 wer~1
will get the desired result (ie it matches star wars
).
How to fix:
The use case you described will work if you configure the Analysis Scheme for the field in question to not use any stemming.
To do this, log into the AWS Web Console and go to Analysis Schemes --> Add Analysis Scheme:
Then go to Indexing Options and configure your field to use your new no-stemming analysis scheme:
Submit your changes and re-index.
That will address your issue but of course you'll lose the benefits of stemming. You can't have your cake and eat it too.