# Suggester doesn't suggest as expected, based on beginning of word

**URL:** https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715
**Category:** Elasticsearch
**Created:** [January 11, 2020, 10:30pm UTC](https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715 "2020-01-11T22:30:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Casper\_Thrane](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casper_thrane/32/49777_2.png) [@Casper\_Thrane](https://discuss.elastic.co/u/Casper_Thrane)
#### Post date: [January 11, 2020, 10:30pm UTC](https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715/1 "2020-01-11T22:30:01Z")

</div>

I want ElasticSearch to suggest more words, based on the beginning of a word. My example is the following. I have these titles:

- **affaldsregister**
- **affaldsdatasystem** - Import af indberetninger
- anmod om ændring af **affaldsordning**
- ansøgning om dispensation for **affaldsregulativ**

I want the suggester to find, the words in bold, when I use the word **affald** or **afald**. I have tried the following:

```auto
POST virk_search_pub_dan/_search 
{
  "suggest": {
    "simple_terms": {
      "text": "affald",
      "term": {
        "max_edits": 1,
        "max_term_freq": 1,
        "max_inspections": 5,
        "field": "title",
        "size": 5,
        "suggest_mode": "always",
        "prefix_length": 3
      }        
    }
  }
}

```

But I get no suggestions. My title field is analyzed with the standard tokenizer. What am I missing?

Br Casper

---

<div class="post-metadata">

### Author: ![Casper\_Thrane](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casper_thrane/32/49777_2.png) [@Casper\_Thrane](https://discuss.elastic.co/u/Casper_Thrane)
#### Post date: [January 13, 2020, 9:36am UTC](https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715/2 "2020-01-13T09:36:52Z")

</div>

I have create an example:

```auto
PUT test

PUT test/_doc/1
{
  "title": "affaldsregister"
}

PUT test/_doc/2
{
  "title": "affaldsdatasystem - Import af indberetninger"
}

PUT test/_doc/3
{
  "title": "anmod om ændring af affaldsordning"
}

PUT test/_doc/4
{ "title": "ansøgning om dispensation for affaldsregulativ " }

POST test/_search
{
  "suggest": {
    "term_suggest": {
      "text": "affald",
      "term": {
        "field": "title"
      }
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 13, 2020, 10:11am UTC](https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715/3 "2020-01-13T10:11:33Z")

</div>

In the example you posted, the edit distance to find a term is too much so elasticsearch can not suggest a correction for your incomplete/typo text.

Here is an example which works:

```auto
GET test/_search
{
  "suggest": {
    "term_suggest": {
      "text": "affaldsdasystem",
      "term": {
        "field": "title"
      }
    }
  }
}

```

It gives:

```auto
{
  "took" : 10,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "suggest" : {
    "term_suggest" : [
      {
        "text" : "affaldsdasystem",
        "offset" : 0,
        "length" : 15,
        "options" : [
          {
            "text" : "affaldsdatasystem",
            "score" : 0.8666667,
            "freq" : 1
          }
        ]
      }
    ]
  }
}

```

If you are looking for completion, read [https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-suggesters.html#completion-suggester](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-suggesters.html#completion-suggester) and [https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-as-you-type.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-as-you-type.html)

---

<div class="post-metadata">

### Author: ![Casper\_Thrane](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casper_thrane/32/49777_2.png) [@Casper\_Thrane](https://discuss.elastic.co/u/Casper_Thrane)
#### Post date: [January 13, 2020, 11:45am UTC](https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715/4 "2020-01-13T11:45:29Z")

</div>

Thanks for the response.

My case is, I have lot of documents, and I want suggestions like Google, based on the text in the documents. I both want single word and phase suggestions. I am not sure, how to do that, with the standard suggesters.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 16, 2020, 3:06pm UTC](https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715/5 "2020-01-16T15:06:05Z")

</div>

I believe this is what [AppSearch](https://www.elastic.co/products/app-search) can provide out of the box.

Otherwise, I think you can combine hopefully multiple suggestions within the same API call???

Not an expert on that part here. Sorry ☹

---

<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: [February 13, 2020, 3:06pm UTC](https://discuss.elastic.co/t/suggester-doesnt-suggest-as-expected-based-on-beginning-of-word/214715/6 "2020-02-13T15:06:10Z")

</div>

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