From 81963cb4c861316e217a67f0a1fdfe051f37c73a Mon Sep 17 00:00:00 2001 From: Alexander van den Berghe Date: Fri, 6 Oct 2023 19:27:21 +0200 Subject: [PATCH] Fix: add an alphanumeric only index field for identifiers --- config/search/config.json | 16 ++++++++++++++-- config/search/dev/config.json | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/config/search/config.json b/config/search/config.json index 08506fa..14ba8d6 100644 --- a/config/search/config.json +++ b/config/search/config.json @@ -67,6 +67,18 @@ "type": "custom", "char_filter": [], "filter": ["lowercase", "trim", "asciifolding"] + }, + "identifier_normalizer": { + "type": "custom", + "char_filter": ["identifier_alphanumeric_filter"], + "filter": ["lowercase", "trim", "asciifolding"] + } + }, + "char_filter": { + "identifier_alphanumeric_filter": { + "type": "pattern_replace", + "pattern": "[^a-zA-Z0-9]", + "replacement": "" } } } @@ -857,9 +869,9 @@ "identifier": { "type": "text", "fields": { - "field": { + "index": { "type": "keyword", - "normalizer": "custom_sort_normalizer" + "normalizer": "identifier_normalizer" } } } diff --git a/config/search/dev/config.json b/config/search/dev/config.json index 59b4741..3400e70 100644 --- a/config/search/dev/config.json +++ b/config/search/dev/config.json @@ -39,6 +39,18 @@ "type": "custom", "char_filter": [], "filter": ["lowercase", "trim", "asciifolding"] + }, + "identifier_normalizer": { + "type": "custom", + "char_filter": ["identifier_alphanumeric_filter"], + "filter": ["lowercase", "trim", "asciifolding"] + } + }, + "char_filter": { + "identifier_alphanumeric_filter": { + "type": "pattern_replace", + "pattern": "[^a-zA-Z0-9]", + "replacement": "" } } } @@ -830,9 +842,9 @@ "identifier": { "type": "text", "fields": { - "field": { + "index": { "type": "keyword", - "normalizer": "custom_sort_normalizer" + "normalizer": "identifier_normalizer" } } }