# Context Suggester 'No mapping defined for"

**URL:** <https://discuss.elastic.co/t/context-suggester-no-mapping-defined-for/34195>\
**Category:** Elasticsearch\
**Created:** [November 9, 2015, 7:50pm UTC](https://discuss.elastic.co/t/context-suggester-no-mapping-defined-for/34195 "2015-11-09T19:50:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joao\_Pedro\_Goncalves](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@Joao\_Pedro\_Goncalves](https://discuss.elastic.co/u/Joao_Pedro_Goncalves)\
**Post date:** [November 9, 2015, 7:50pm UTC](https://discuss.elastic.co/t/context-suggester-no-mapping-defined-for/34195/1 "2015-11-09T19:50:54Z")

</div>

NEW ERROR:

Hi again. Im updating the main post, to be more visible the problem. Im trying to do context suggest, and in all shard i get the following error:

```
{
  "_shards": {
    "total": 5,
    "successful": 0,
    "failed": 5,
    "failures": [
      {
        "index": "app",
        "shard": 0,
        "status": 500,
        "reason": "BroadcastShardOperationFailedException[[app][0] ]; nested: ElasticsearchException[failed to execute suggest]; nested: ElasticsearchParseException[no mapping defined for [users]]; "
      }
}

```

And here the mapping for user:

```
{
  "app" : {
    "mappings" : {
      "users" : {
        "properties" : {
          "document" : {
            "type" : "string"
          },
          "email" : {
            "type" : "string"
          },
          "first_name" : {
            "type" : "string"
          },
          "group" : {
            "type" : "string"
          },
          "last_name" : {
            "type" : "string"
          },
          "suggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "payloads" : true,
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50,
            "context" : {
              "users" : {
                "type" : "category",
                "path" : "_type",
                "default" : ["users_active"]
              }
            }
          }
        }
      }
    }
  }
}

```

OLD ERROR:

> Hello friends, I have a strange bug happening in my project. Im using PHP client of ES.

> When I start my application for the first time, automatically creates all mappings in the same way, only changing necessary params. And all of them is created correctly.

> After that, every time I add something to my database automatically creates a document in the correct index. And everything works same for both, only changing necessary params.

> For some reason that I can't figure out, every time that I create an user, he is creating a mapping inside the user mapping, and this only happens with users type. Every other type is creating correctly, and in the same way.

> I searched for everything inside my code, but nothing makes any sense, because the same way I do to others documents insertions, I do for this one. And every dump I did before creating a document is identical for any insertion method. I really don't know what the problem is...

---

<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:** [November 9, 2015, 8:09pm UTC](https://discuss.elastic.co/t/context-suggester-no-mapping-defined-for/34195/2 "2015-11-09T20:09:30Z")

</div>

Looks like you have a users field inside your json doc.

Can you GET a sample doc so we can see how it looks?

---

<div class="post-metadata">

**Author:** ![Joao\_Pedro\_Goncalves](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@Joao\_Pedro\_Goncalves](https://discuss.elastic.co/u/Joao_Pedro_Goncalves)\
**Post date:** [November 9, 2015, 8:17pm UTC](https://discuss.elastic.co/t/context-suggester-no-mapping-defined-for/34195/3 "2015-11-09T20:17:50Z")

</div>

Hey, thanks for help.

Well indeed I find something wrong, and now its creating document correctly. But now created another problem.

Im using suggest context, and again only in users I receive this problem.

```
{"_shards":{"total":5,"successful":0,"failed":5,"failures":[{"index":"app","shard":0,"status":500,"reason":"BroadcastShardOperationFailedException[[app][0] ]; nested: ElasticsearchException[failed to execute suggest]; nested: ElasticsearchParseException[no mapping defined for [users]]; "},

```

And mapping:

```
{
 "app" : {
    "mappings" : {
      "users" : {
        "properties" : {
          "document" : {
            "type" : "string"
          },
          "email" : {
            "type" : "string"
          },
          "first_name" : {
            "type" : "string"
          },
          "group" : {
            "type" : "string"
          },
          "last_name" : {
            "type" : "string"
          },
          "suggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "payloads" : true,
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50,
            "context" : {
              "users" : {
                "type" : "category",
                "path" : "_type",
                "default" : ["users_active"]
              }
            }
          }
        }
      }
    }
  }
}

```

and how Im sending params to es client

```
 array:1 [
  "body" => array:1 [
    "app" => array:2 [
      "text" => "test"
      "completion" => array:4 [
        "field" => "suggest"
        "size" => 10
        "context" => array:1 [
          "users" => "users_active"
        ]
        "fuzzy" => array:1 [
          "fuzziness" => 2
        ]
      ]
    ]
  ]
]

```

and GET

```
{
  "_index" : "app",
  "_type" : "users",
  "_id" : "5641001fbffebcc5098b4567",
  "_version" : 3,
  "found" : true,
  "_source":{"first_name":"joao","last_name":"test","email":"test@test.com","document":"159","group":"Admin","suggest":{"input":["joao","test","joaokmz@gmail.com","159","Admin"],"output":["joao test (joaokmz@gmail.com)"],"context":{"users":"users_active"},"payload":{"id":"5641001fbffebcc5098b4567","extra_info":"Admin"}}}
}
```

---

<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 5, 2017, 11:39pm UTC](https://discuss.elastic.co/t/context-suggester-no-mapping-defined-for/34195/4 "2017-07-05T23:39:40Z")

</div>


