Custom analyzer on multi field error (ES version 5.1.1 PHP API)

Hello,

We are trying to upgrade from ES version 2.3.1 to 5.1.1. So now I'm changing the code to create the index and the mapping, but I'm getting this strange error message.

Elasticsearch Error: mapper_parsing_exception: Mapping definition for [fields] has unsupported parameters: [analyzer : lowercase] (400)

The code I use to create the index and mapping:

$aParams = [
	'index' => 'my_index',
	'body' => [
		'settings' => [
			'analysis' => [
				'analyzer' => [
					'lowercase' => [
						'type' => 'custom',
						'tokenizer' => 'keyword',
						'filter' => [ 'lowercase' ],
					]
				]
			]
		]
	]
];
$oElastic->indices()->create( $aParams );

$aMapping = [
	'index' => 'my_index',
	'type' => 'my_type',
	'body' => [
		'my_type' => [
			'_source' => [
				'enabled' => true,
			],
			'properties' => [
				'my_field' => [
					'type' => 'keyword',
					'analyzer' => 'dutch',
					'fields' => [
						'lowercase' => [
							'type' => 'keyword',
							'analyzer' => 'lowercase',
						],
						'raw' => [
							'type' => 'keyword',
							'index' => false,
						]
					]
				]
			]
		]
	]
];
$oElastic->indices()->putMapping( $aMapping );

Any thoughts?

Hi @barry1,

Analyzers on keyword fields are not supported in Elasticsearch 5.1.1.. We have implemented support for that in #21919 which is coming in Elasticsearch 5.2. It's hard to tell from your example but did you check you need a keyword field instead of a text field?

Daniel

Aha, I see.

The code I gave is just an simplified example. We're building our mapping based on a dynamic mysql database, so every varchar will become a text now instead of a keyword (was string in 2.3).

Maybe I can do some less dynamic stuff a see if some varchar's need to be a keyword and some other have to be text.

Thank's for the solution!

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