Completion suggester is not prefix matching

I followed the instructions here Search experience - OpenSearch documentation (scroll down to the section on Completion Suggesters) but when I do a prefix search, I get back documents that match my search term anywhere, not just as a prefix.

For example, this search

  "suggest": {
    "displayname-suggestion": {
      "prefix": "man",      
      "completion": {
        "field": "displayName"        

Results in suggestions like:

                        "text": "100man",
                        "_index": "displayname_complete_index",
                        "_type": "_doc",
                        "_id": "fa721a71-fa13-5725-8b28-d66f709a661c",
                        "_score": 1.0,
                        "_source": {
                            "displayName": "100man"

FYI my index is defined as:

    "displayname_complete_index": {
        "aliases": {},
        "mappings": {
            "properties": {
                "displayName": {
                    "type": "completion",
                    "analyzer": "simple",
                    "preserve_separators": true,
                    "preserve_position_increments": true,
                    "max_input_length": 50
        "settings": {
            "index": {
                "creation_date": "1657639762564",
                "number_of_shards": "5",
                "number_of_replicas": "1",
                "uuid": "679HeXUeRv-OfpsZJVfU6w",
                "version": {
                    "created": "135238227"
                "provided_name": "displayname_complete_index"

What am I doing wrong here?

In case anyone else comes across this, the issue was not with the completion suggester, it was with the analyzer I was using.

The simple analyzer disregards numbers so it was matching on prefixes with numbers before it.
Using the standard analyzer solved my problem.

1 Like