Skip to content

Instantly share code, notes, and snippets.

@micheleorselli
Last active April 6, 2017 14:14
Show Gist options
  • Save micheleorselli/6ce84d1a72dff355e3f3a43caab77db3 to your computer and use it in GitHub Desktop.
Save micheleorselli/6ce84d1a72dff355e3f3a43caab77db3 to your computer and use it in GitHub Desktop.
normalizer mapping
private static $mapping = [
'fiscalCode' => ['type' => 'keyword', 'include_in_all' => false],
'vatNumber' => ['type' => 'keyword', 'include_in_all' => false],
'businessName' => ['type' => 'keyword', 'include_in_all' => true,],
'city' => ['type' => 'keyword', 'normalizer' => 'lowercase_asciifolding', 'include_in_all' => false],
'createdAt' => ['type' => 'keyword', 'include_in_all' => false],
];
$settings = [
'settings' => [
'index' => [
'number_of_shards' => 4,
'number_of_replicas' => 0,
'analysis' => [
'normalizer' => [
'lowercase_asciifolding' => [
'type' => 'custom',
'char_filter' => [],
'filter' => ['lowercase', 'asciifolding'],
],
],
]
]
]
];
$index = $this->elasticaClient->getIndex($this->indexName);
$index->create($settings , true);
$mapping = new Mapping();
$mapping->setProperties(self::$mapping);
$elasticaType = $index->getType(self::TYPE);
$elasticaType->setMapping($mapping);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment