putMapping "reason":"Rejecting mapping update to [pets] as the final mapping would have more than 1 type: [bird, dog]"}]


(Nickclasener) #1

I can't decipher what's wrong with my code.
Im using the elasticsearch-php package > json-doc,
elasticsearch-php > php-doc.
my putMapping function

	public function elasticsearchData()
	{
		$params = [
			'index'            => 'pets',
			'type'             => 'bird',
			'body'             => [
				'bird' => [
					'_source' => [
						'enabled' => true
					],
					'properties' => [
						'name'       => ['type' => 'text'],
						'age'        => ['type' => 'long'],
						'gender'     => ['type' => 'boolean'],
						'color'      => ['type' => 'text'],
						'braveBird'  => ['type' => 'boolean'],
						'hometown'   => ['type' => 'text'],
						'about'      => ['type' => 'text'],
						'registered' => ['type' => 'date'],
					]
				]
			]
		];

		$response = $this->elasticsearch->indices()->putMapping($params);
		dd($response);

		$params = [
			'index' => 'pets',
			'type'  => 'bird'
		];

		$response = $this->elasticsearch->indices()->getMapping($params);
		dump($response);
	}

The response i get

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [pets] as the final mapping would have more than 1 type: [bird, dog]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [pets] as the final mapping would have more than 1 type: [bird, dog]"},"status":400}

(David Pilato) #2

You already have a type defined for your index.
You can't add another one in 6.x.


(Nickclasener) #3

Yes i read that since 6.0 you can only have single types...?
What this exactly means isn't yet clear to me
Do i structure it like this?
Index: dog type: pet
index: bird type: pet


(David Pilato) #4

You can read this: https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch


(system) #5

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