# Phrase Suggester doesn't work with short prefixes?

**URL:** <https://discuss.elastic.co/t/phrase-suggester-doesnt-work-with-short-prefixes/276569>\
**Category:** Elasticsearch\
**Created:** [June 21, 2021, 5:56pm UTC](https://discuss.elastic.co/t/phrase-suggester-doesnt-work-with-short-prefixes/276569 "2021-06-21T17:56:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabetai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sabetai/32/82900_2.png) [@sabetai](https://discuss.elastic.co/u/sabetai)\
**Post date:** [June 21, 2021, 5:56pm UTC](https://discuss.elastic.co/t/phrase-suggester-doesnt-work-with-short-prefixes/276569/1 "2021-06-21T17:56:49Z")

</div>

I'm trying to implement simple auto-complete where entering the prefix of a phrase will retrieve auto-complete suggestions (ie for phrase size of 3-5). However, the `Phrase Suggester` often doesn't yield results until the word is almost finished. How can I fix this to suggest phrases after say, three characters have been entered?

Settings:

```auto
PUT test
{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "analysis": {
        "analyzer": {
          "trigram": {
            "type": "custom",
            "tokenizer": "standard",
            "filter": ["lowercase","shingle"]
          },
          "reverse": {
            "type": "custom",
            "tokenizer": "standard",
            "filter": ["lowercase","reverse"]
          }
        },
        "filter": {
          "shingle": {
            "type": "shingle",
            "min_shingle_size": 2,
            "max_shingle_size": 3
          }
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "fields": {
          "trigram": {
            "type": "text",
            "analyzer": "trigram"
          },
          "reverse": {
            "type": "text",
            "analyzer": "reverse"
          }
        }
      }
    }
  }
}

```

Test entry:

```auto
POST test/_doc?refresh=true
{"title": "Division A contains compliance and application provisions and the"}

```

If I wanted to auto-complete a phrase such as "division a contains", I'll only get options after most of the phrase is already complete ie "division a contai".

Example query:

```auto
POST suggestor-test/_search
{
  "suggest": {
    "text": "division a conta",
    "simple_phrase": {
      "phrase": {
        "field": "title.trigram",
        "size": 1,
        "gram_size": 3,
        "direct_generator": [ {
          "field": "title.trigram",
          "suggest_mode": "always"
        } ]
      }
    }
  }
}

```

How can I improve the results?

---

<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 19, 2021, 5:57pm UTC](https://discuss.elastic.co/t/phrase-suggester-doesnt-work-with-short-prefixes/276569/2 "2021-07-19T17:57:43Z")

</div>

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