# Possible bug in completion context suggester (6.8 and 7.10)

**URL:** https://discuss.elastic.co/t/possible-bug-in-completion-context-suggester-6-8-and-7-10/275718
**Category:** Elasticsearch
**Created:** [June 11, 2021, 8:10pm UTC](https://discuss.elastic.co/t/possible-bug-in-completion-context-suggester-6-8-and-7-10/275718 "2021-06-11T20:10:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bklippel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bklippel/32/90193_2.png) [@bklippel](https://discuss.elastic.co/u/bklippel)
#### Post date: [June 11, 2021, 8:10pm UTC](https://discuss.elastic.co/t/possible-bug-in-completion-context-suggester-6-8-and-7-10/275718/1 "2021-06-11T20:10:22Z")

</div>

Hi, I've come across some strange behavior using the completion suggest. In my scenario it seems that inputs over ~34 characters are ignored. I have steps to reproduce.

Create this index, post this doc then try the query, then edit and re-index the doc with a slightly shorter nameSuggest.input (take 1 char off the end), and try again. I have tried with 6.8 and 7.10, same result. I have set the max\_input\_length to 500, which unsurprisingly didn't help since the issue is occurring before the default of 50.

```auto
PUT suggest-test
{
  "settings": {
    "index": {
      "mapping": {
        "ignore_malformed": "true"
      },
      "refresh_interval": "1s",
      "number_of_shards": "4",
      "sort": {
        "field": "suggestType"
      },
      "analysis": {
        "filter": {
          "ngram_filter": {
            "type": "edge_ngram",
            "min_gram": "1",
            "max_gram": "24"
          }
        },
        "analyzer": {
          "whitespace_analyzer": {
            "type": "custom",
            "tokenizer": "lowercase"
          },
          "ngram_analyzer": {
            "filter": [
              "ngram_filter",
              "lowercase"
            ],
            "type": "custom",
            "tokenizer": "lowercase"
          }
        }
      },
      "number_of_replicas": "1"
    }
  },
  "mappings": {
    "properties": {
      "createdDate": {
        "type": "date"
      },
      "healthSystemId": {
        "type": "keyword"
      },
      "id": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "imageUrl": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "inputNgram": {
        "type": "text",
        "analyzer": "ngram_analyzer",
        "search_analyzer": "whitespace_analyzer"
      },
      "inputValue": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "modifiedDate": {
        "type": "date"
      },
      "nameSuggest": {
        "type": "completion",
        "analyzer": "ngram_analyzer",
        "search_analyzer": "whitespace_analyzer",
        "preserve_separators": true,
        "preserve_position_increments": false,
        "max_input_length": 500,
        "contexts": [
          {
            "name": "HealthSystemId",
            "type": "CATEGORY",
            "path": "healthSystemId"
          },
          {
            "name": "SuggestType",
            "type": "CATEGORY",
            "path": "suggestType"
          },
          {
            "name": "SuggestSubType",
            "type": "CATEGORY",
            "path": "suggestSubType"
          }
        ]
      },
      "objectType": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "relatedCount": {
        "type": "long"
      },
      "searchAttributeName": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "sourceReference": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "sourceReferenceExternal": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "sourceReferenceSecondary": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "subType": {
        "type": "keyword"
      },
      "suggest": {
        "type": "completion",
        "analyzer": "whitespace_analyzer",
        "preserve_separators": true,
        "preserve_position_increments": false,
        "max_input_length": 500,
        "contexts": [
          {
            "name": "HealthSystemId",
            "type": "CATEGORY",
            "path": "healthSystemId"
          },
          {
            "name": "SuggestType",
            "type": "CATEGORY",
            "path": "suggestType"
          },
          {
            "name": "SuggestSubType",
            "type": "CATEGORY",
            "path": "suggestSubType"
          }
        ]
      },
      "suggestSubType": {
        "type": "keyword"
      },
      "suggestType": {
        "type": "keyword"
      },
      "suggestedValue": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "type": {
        "type": "keyword"
      }
    }
  }
}

```

```auto
PUT /suggest-test/_doc/PDS215725
{
    "healthSystemId" : 197,
    "id" : "PDS215725",
    "type" : "Specialty",
    "subType" : [],
    "suggestType" : "197-Specialty",
    "suggestSubType" : ["5c478f3a47d751d586b66baf1ea952a51"],
    "inputValue" : "Vascular and Interventional Radiology",
    "nameSuggest" : {
      "input" : ["Vascular and Interventional Radiology Te"]
    },
    "suggestedValue" : "Marketing Published Specialty:Vascular and Interventional Radiology",
    "searchAttributeName" : "specialtyDomains.specialties.specialtyFullName",
    "sourceReference" : "215724",
    "sourceReferenceSecondary" : "",
    "createdDate" : "2021-06-11T05:09:18",
    "modifiedDate" : "2021-06-11T05:09:18",
    "objectType" : "provider",
    "relatedCount" : 0
  }    

```

```auto
POST /suggest-test/_search
 {
        "size": 100,
        "suggest": {
            "specialty": {
                "completion": {
                    "contexts": {
                        "SuggestSubType": [
                            {
                                "context": "5c478f3a47d751d586b66baf1ea952a51"
                            }
                        ]
                    },
                    "field": "nameSuggest",
                    "size": 100
                },
                "prefix": "vascular"
            }
        }
    }

```

no result...

```auto
PUT /suggest-test/_doc/PDS215725
{
    "healthSystemId" : 197,
    "id" : "PDS215725",
    "type" : "Specialty",
    "subType" : [],
    "suggestType" : "197-Specialty",
    "suggestSubType" : ["5c478f3a47d751d586b66baf1ea952a51"],
    "inputValue" : "Vascular and Interventional Radiology",
    "nameSuggest" : {
      "input" : ["Vascular and Interventional Radiology T"]
    },
    "suggestedValue" : "Marketing Published Specialty:Vascular and Interventional Radiology",
    "searchAttributeName" : "specialtyDomains.specialties.specialtyFullName",
    "sourceReference" : "215724",
    "sourceReferenceSecondary" : "",
    "createdDate" : "2021-06-11T05:09:18",
    "modifiedDate" : "2021-06-11T05:09:18",
    "objectType" : "provider",
    "relatedCount" : 0
  }    

```

```auto
POST /suggest-test/_search
 {
        "size": 100,
        "suggest": {
            "specialty": {
                "completion": {
                    "contexts": {
                        "SuggestSubType": [
                            {
                                "context": "5c478f3a47d751d586b66baf1ea952a51"
                            }
                        ]
                    },
                    "field": "nameSuggest",
                    "size": 100
                },
                "prefix": "vascular"
            }
        }
    }

```

1 result!

What is going on here?

Thanks,  
Brian

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 9, 2021, 8:11pm UTC](https://discuss.elastic.co/t/possible-bug-in-completion-context-suggester-6-8-and-7-10/275718/2 "2021-07-09T20:11:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
