# Trouble with suggestions

**URL:** <https://discuss.elastic.co/t/trouble-with-suggestions/321673>\
**Category:** Elasticsearch\
**Created:** [December 20, 2022, 4:56pm UTC](https://discuss.elastic.co/t/trouble-with-suggestions/321673 "2022-12-20T16:56:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mihai\_Raulea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mihai_raulea/32/114971_2.png) [@Mihai\_Raulea](https://discuss.elastic.co/u/Mihai_Raulea)\
**Post date:** [December 20, 2022, 4:56pm UTC](https://discuss.elastic.co/t/trouble-with-suggestions/321673/1 "2022-12-20T16:56:00Z")

</div>

i have a skills index with the following mapping:

```auto
{
  "skills" : {
    "mappings" : {
      "properties" : {
        "skill" : {
          "type" : "completion",
          "analyzer" : "simple",
          "preserve_separators" : true,
          "preserve_position_increments" : true,
          "max_input_length" : 50
        }
      }
    }
  }
}

```

The index is populated with around 2000 items. Here is a sample search result:

```auto
{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":10000,"relation":"gte"},"max_score":1.0,"hits":[{"_index":"skills","_id":"ZjQtMIUB7n2f4Nbeg4Qr","_score":1.0,"_source":
    {
      "skill": "liderazgo de equipos"
    }
    },{"_index":"skills","_id":"ZzQtMIUB7n2f4Nbeg4Q-","_score":1.0,"_source":
    {
      "skill": "key account management"
    }
    },{"_index":"skills","_id":"aDQtMIUB7n2f4Nbeg4RN","_score":1.0,"_source":
    {
      "skill": "security"
    }
    },{"_index":"skills","_id":"aTQtMIUB7n2f4Nbeg4Ra","_score":1.0,"_source":
    {
      "skill": "quality assurance"
    }
    },{"_index":"skills","_id":"ajQtMIUB7n2f4Nbeg4Ro","_score":1.0,"_source":
    {
      "skill": "healthcare management"
    }
    },{"_index":"skills","_id":"azQtMIUB7n2f4Nbeg4R1","_score":1.0,"_source":
    {
      "skill": "program development"
    }
    },{"_index":"skills","_id":"bDQtMIUB7n2f4Nbeg4SG","_score":1.0,"_source":
    {
      "skill": "curriculum development"
    }
    },{"_index":"skills","_id":"bTQtMIUB7n2f4Nbeg4SU","_score":1.0,"_source":
    {
      "skill": "hospitality"
    }
    },{"_index":"skills","_id":"bjQtMIUB7n2f4Nbeg4Sh","_score":1.0,"_source":
    {
      "skill": "supply chain"
    }
    },{"_index":"skills","_id":"bzQtMIUB7n2f4Nbeg4Sv","_score":1.0,"_source":
    {
      "skill": "investments"
    }
    }]}}

```

when i run

```auto

curl -X POST "localhost:9200/skills/_suggest" -H 'Content-Type: application/json' -d'
{
  "skill-suggest": {
    "prefix": "ja",
    "completion": {
      "field": "skill"
    }
  }
}
'

```

i get an error:

`{"error":"no handler found for uri [/skills/_suggest] and method [POST]"}`

The index does exist(i am able to list its content).  
The elasticsearch endpoint is the correct one - i am able to run other queries successfully.  
Elasticsearch is running and accesible.

Running

```auto
curl -X POST "localhost:9200/skills/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "_source": "suggest",     
  "suggest": {
    "song-suggest": {
      "prefix": "ja",
      "completion": {
        "field": "skill", 
        "size": 5           
      }
    }
  }
}
'
{
  "took" : 11,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "suggest" : {
    "song-suggest" : [
      {
        "text" : "ja",
        "offset" : 0,
        "length" : 2,
        "options" : [
          {
            "text" : "japan",
            "_index" : "skills",
            "_id" : "kTQvMIUB7n2f4NbeXqFg",
            "_score" : 1.0,
            "_source" : { }
          },
          {
            "text" : "japan",
            "_index" : "skills",
            "_id" : "oTQxMIUB7n2f4NbevcgW",
            "_score" : 1.0,
            "_source" : { }
          },
          {
            "text" : "japan",
            "_index" : "skills",
            "_id" : "sTQ0MIUB7n2f4NbeIu8F",
            "_score" : 1.0,
            "_source" : { }
          },
          {
            "text" : "japan",
            "_index" : "skills",
            "_id" : "wTU2MIUB7n2f4NbefBZJ",
            "_score" : 1.0,
            "_source" : { }
          },
          {
            "text" : "japan",
            "_index" : "skills",
            "_id" : "0TU5MIUB7n2f4NbeHj2R",
            "_score" : 1.0,
            "_source" : { }
          }
        ]
      }
    ]
  }
}

```

gives 5 disappointing "japan" results, even though i have 100% unique values in the skills index.

Expectation: find a way to get relevant suggestions. Typing "ja" should give me answers such as java, javascript.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [December 20, 2022, 5:00pm UTC](https://discuss.elastic.co/t/trouble-with-suggestions/321673/2 "2022-12-20T17:00:30Z")

</div>

Hi @Mihai_Raulea

Please use the code formatting tools in the code snippets. Using vc formatting helps everyone understand and reproduce your problem.

---

<div class="post-metadata">

**Author:** ![Mihai\_Raulea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mihai_raulea/32/114971_2.png) [@Mihai\_Raulea](https://discuss.elastic.co/u/Mihai_Raulea)\
**Post date:** [December 20, 2022, 5:12pm UTC](https://discuss.elastic.co/t/trouble-with-suggestions/321673/3 "2022-12-20T17:12:15Z")

</div>

[autocomplete - elasticsearch completion suggester returns only one suggestion when more than one matches - Stack Overflow](https://stackoverflow.com/questions/70955283/elasticsearch-completion-suggester-returns-only-one-suggestion-when-more-than-on) -- it's basically the same problem.

---

<div class="post-metadata">

**Author:** ![Mihai\_Raulea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mihai_raulea/32/114971_2.png) [@Mihai\_Raulea](https://discuss.elastic.co/u/Mihai_Raulea)\
**Post date:** [December 20, 2022, 5:16pm UTC](https://discuss.elastic.co/t/trouble-with-suggestions/321673/4 "2022-12-20T17:16:18Z")

</div>

Hi Rabbit, i have formatted my query. Thanks!

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [December 20, 2022, 7:16pm UTC](https://discuss.elastic.co/t/trouble-with-suggestions/321673/5 "2022-12-20T19:16:06Z")

</div>

I understand that you want to manipulate the order of suggestions. In that case I think using weight can help

> weight: A positive integer or a string containing a positive integer, which defines a weight and allows you to rank your suggestions. This field is optional.

---

<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:** [January 17, 2023, 7:16pm UTC](https://discuss.elastic.co/t/trouble-with-suggestions/321673/6 "2023-01-17T19:16:56Z")

</div>

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