<commit_before>[[return-suggesters-type]]
==== Returning the type of the suggester

Sometimes you need to know the exact type of a suggester in order to parse its results. The `typed_keys` parameter
 can be used to change the suggester's name in the response so that it will be prefixed by its type.

Considering the following example with two suggesters `term` and `phrase`:

[source,console]
--------------------------------------------------
POST _search?typed_keys
{
  "suggest": {
    "text" : "some test mssage",
    "my-first-suggester" : {
      "term" : {
        "field" : "message"
      }
    },
    "my-second-suggester" : {
      "phrase" : {
        "field" : "message"
      }
    }
  }
}
--------------------------------------------------
// TEST[setup:twitter]

In the response, the suggester names will be changed to respectively `term#my-first-suggester` and
`phrase#my-second-suggester`, reflecting the types of each suggestion:

[source,console-result]
--------------------------------------------------
{
  "suggest": {
    "term#my-first-suggester": [ <1>
      {
        "text": "some",
        "offset": 0,
        "length": 4,
        "options": []
      },
      {
        "text": "test",
        "offset": 5,
        "length": 4,
        "options": []
      },
      {
        "text": "mssage",
        "offset": 10,
        "length": 6,
        "options": [
          {
            "text": "message",<commit_msg>Mute test failing in #54257 (#54258)<commit_after>[[return-suggesters-type]]
==== Returning the type of the suggester

Sometimes you need to know the exact type of a suggester in order to parse its results. The `typed_keys` parameter
 can be used to change the suggester's name in the response so that it will be prefixed by its type.

Considering the following example with two suggesters `term` and `phrase`:

[source,console]
--------------------------------------------------
POST _search?typed_keys
{
  "suggest": {
    "text" : "some test mssage",
    "my-first-suggester" : {
      "term" : {
        "field" : "message"
      }
    },
    "my-second-suggester" : {
      "phrase" : {
        "field" : "message"
      }
    }
  }
}
--------------------------------------------------
// TEST[setup:twitter]
// TEST[skip:awaits fix of https://github.com/elastic/elasticsearch/issues/54257]

In the response, the suggester names will be changed to respectively `term#my-first-suggester` and
`phrase#my-second-suggester`, reflecting the types of each suggestion:

[source,console-result]
--------------------------------------------------
{
  "suggest": {
    "term#my-first-suggester": [ <1>
      {
        "text": "some",
        "offset": 0,
        "length": 4,
        "options": []
      },
      {
        "text": "test",
        "offset": 5,
        "length": 4,
        "options": []
      },
      {
        "text": "mssage",
        "offset": 10,
        "length": 6,
        "options": [
          {
            "text": "message",
{'fraction_non_alphanumeric': 0.22716627634660422, 'fraction_numerical': 0.010371361659417865, 'mean_word_length': 1.6840215439856374, 'pattern_counts': {'":': 32, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3622855', 'n_tokens_mistral': 924, 'n_tokens_neox': 870, 'n_words': 250}