From df5b51acfe8aabef66e1732a76bb46fe0ff3bd9e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 29 Aug 2022 22:32:05 +0000 Subject: [PATCH] Bug 27153: POC This is a small example to show that we can add an extra field to our default indexing that removes punctuation. If we then add that field to the fields we push, we can sarch both the regular and the punctuation stripped version To complete this we would need to add a 'search variations' field to the ES config page, for the user to decide which fields should be searched in all variations, and which shouldn't Or we could add this to all 'simple searches' from the search bar, and only search exact on advanced searches. I am happy to explore either option --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 1 + admin/searchengine/elasticsearch/field_config.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 174ba62626..0524071bfb 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -197,6 +197,7 @@ sub build_query { if ($options{whole_record}) { push @$fields, 'marc_data_array.*'; } + push @$fields, 'title.punc_removed'; $res->{query} = { query_string => { query => $query, diff --git a/admin/searchengine/elasticsearch/field_config.yaml b/admin/searchengine/elasticsearch/field_config.yaml index cf90482aa2..6b64eec968 100644 --- a/admin/searchengine/elasticsearch/field_config.yaml +++ b/admin/searchengine/elasticsearch/field_config.yaml @@ -53,6 +53,9 @@ search: ci_raw: type: keyword normalizer: icu_folding_normalizer + punc_removed: + type: text + analyzer: analyzer_stdno # Facets facet: default: -- 2.30.2