Context Suggester 'No mapping defined for"

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...

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

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

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"}}}
}