Phrase Suggester doesn't work with short prefixes?

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:

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:

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:

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?

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