From aca756e64d0ae7e94390058f968bb73065325d68 Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 7 Oct 2021 22:44:32 +0200 Subject: [PATCH] search api autocomplete withour accent, and splitting numbers (fruhstuck40) --- config/sync/search_api.index.autocomplete.yml | 6 +- ...pi.server.database_search_autocomplete.yml | 10 ++-- ...d_type.text_edgestring_ascii_und_6_0_0.yml | 56 +++++++++++++++++++ ...d_type.text_edgestring_ascii_und_6_0_0.yml | 52 +++++++++++++++++ .../src/Controller/FormAutocomplete.php | 5 +- 5 files changed, 119 insertions(+), 10 deletions(-) create mode 100644 config/sync/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml create mode 100644 web/modules/custom/materio_sapi/config/install/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml diff --git a/config/sync/search_api.index.autocomplete.yml b/config/sync/search_api.index.autocomplete.yml index 14a92d6..e066671 100644 --- a/config/sync/search_api.index.autocomplete.yml +++ b/config/sync/search_api.index.autocomplete.yml @@ -7,7 +7,6 @@ dependencies: - taxonomy - synonyms - search_api - - materio_sapi config: - field.storage.taxonomy_term.field_synonyms - search_api.server.database_search_autocomplete @@ -61,7 +60,7 @@ field_settings: label: Synonyms datasource_id: 'entity:taxonomy_term' property_path: field_synonyms - type: 'solr_text_custom:edgestring' + type: 'solr_text_custom:edgeasciistring' dependencies: config: - field.storage.taxonomy_term.field_synonyms @@ -69,7 +68,7 @@ field_settings: label: Name datasource_id: 'entity:taxonomy_term' property_path: name - type: 'solr_text_custom:edgestring' + type: 'solr_text_custom:edgeasciistring' boost: !!float 2 dependencies: module: @@ -119,7 +118,6 @@ processor_settings: solr_date_range: weights: preprocess_index: 0 - term_used: { } type_boost: boosts: 'entity:taxonomy_term': diff --git a/config/sync/search_api.server.database_search_autocomplete.yml b/config/sync/search_api.server.database_search_autocomplete.yml index d37862b..5bdea33 100644 --- a/config/sync/search_api.server.database_search_autocomplete.yml +++ b/config/sync/search_api.server.database_search_autocomplete.yml @@ -9,6 +9,7 @@ dependencies: - search_api_solr.solr_cache.cache_persegfilter_default_7_0_0 - search_api_solr.solr_cache.cache_queryresult_default_7_0_0 - search_api_solr.solr_field_type.text_edge_und_7_0_0 + - search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0 - search_api_solr.solr_field_type.text_edgestring_und_6_0_0 - search_api_solr.solr_field_type.text_en_7_0_0 - search_api_solr.solr_field_type.text_fr_7_0_0 @@ -47,9 +48,10 @@ backend_config: commit_within: 1000 solr_version: '8' http_method: AUTO - jmx: false - solr_install_dir: ../../.. skip_schema_check: false + jmx: false + jts: false + solr_install_dir: ../../.. disabled_field_types: { } disabled_caches: { } disabled_request_handlers: @@ -59,12 +61,12 @@ backend_config: disabled_request_dispatchers: - request_dispatcher_httpcaching_default_7_0_0 rows: 10 + index_single_documents_fallback_count: 10 retrieve_data: true highlight_data: false + fallback_multiple: true server_prefix: '' domain: generic environment: default optimize: false site_hash: true - index_single_documents_fallback_count: 10 - fallback_multiple: true diff --git a/config/sync/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml b/config/sync/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml new file mode 100644 index 0000000..32539dc --- /dev/null +++ b/config/sync/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml @@ -0,0 +1,56 @@ +uuid: af25836c-6eca-4621-a803-7a7394fff660 +langcode: en +status: true +dependencies: { } +_core: + default_config_hash: 2jPHrZPHYA4ZBHAbJDAoVD465MybfBXiepOZsUHyg-o +id: text_edgestring_ascii_und_6_0_0 +label: 'Edge NGram ASCII String Field' +minimum_solr_version: 6.0.0 +custom_code: edgeasciistring +field_type_language_code: und +domains: { } +field_type: + name: text_edgenasciistring + class: solr.TextField + positionIncrementGap: 100 + analyzers: + - + type: index + tokenizer: + class: solr.StandardTokenizerFactory + filters: + - + class: solr.LowerCaseFilterFactory + - + class: solr.RemoveDuplicatesTokenFilterFactory + - + class: solr.EdgeNGramFilterFactory + minGramSize: 2 + maxGramSize: 25 + - + class: solr.ASCIIFoldingFilterFactory + preserveOriginal: true + - + class: solr.WordDelimiterGraphFilterFactory + preserveOriginal: 1 + - + type: query + tokenizer: + class: solr.StandardTokenizerFactory + filters: + - + class: solr.LowerCaseFilterFactory + - + class: solr.RemoveDuplicatesTokenFilterFactory + - + class: solr.ASCIIFoldingFilterFactory + preserveOriginal: true + - + class: solr.WordDelimiterGraphFilterFactory + preserveOriginal: 1 +unstemmed_field_type: null +spellcheck_field_type: null +collated_field_type: null +solr_configs: { } +text_files: { } diff --git a/web/modules/custom/materio_sapi/config/install/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml b/web/modules/custom/materio_sapi/config/install/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml new file mode 100644 index 0000000..372180f --- /dev/null +++ b/web/modules/custom/materio_sapi/config/install/search_api_solr.solr_field_type.text_edgestring_ascii_und_6_0_0.yml @@ -0,0 +1,52 @@ +langcode: en +status: true +dependencies: + module: + - search_api_solr +id: text_edgestring_ascii_und_6_0_0 +label: 'Edge NGram ASCII String Field' +minimum_solr_version: 6.0.0 +custom_code: 'edgeasciistring' +field_type_language_code: und +domains: {} +field_type: + name: text_edgenasciistring + class: solr.TextField + positionIncrementGap: 100 + analyzers: + - + type: index + tokenizer: + class: solr.StandardTokenizerFactory + filters: + - + class: solr.LowerCaseFilterFactory + - + class: solr.RemoveDuplicatesTokenFilterFactory + - + class: solr.EdgeNGramFilterFactory + minGramSize: 2 + maxGramSize: 25 + - + class: solr.ASCIIFoldingFilterFactory + preserveOriginal: true + - + class: solr.WordDelimiterGraphFilterFactory + preserveOriginal: 1 + - + type: query + tokenizer: + class: solr.StandardTokenizerFactory + filters: + - + class: solr.LowerCaseFilterFactory + - + class: solr.RemoveDuplicatesTokenFilterFactory + - + class: solr.ASCIIFoldingFilterFactory + preserveOriginal: true + - + class: solr.WordDelimiterGraphFilterFactory + preserveOriginal: 1 +solr_configs: {} +text_files: {} diff --git a/web/modules/custom/materio_sapi/src/Controller/FormAutocomplete.php b/web/modules/custom/materio_sapi/src/Controller/FormAutocomplete.php index 1cb9ba9..6fd8fac 100644 --- a/web/modules/custom/materio_sapi/src/Controller/FormAutocomplete.php +++ b/web/modules/custom/materio_sapi/src/Controller/FormAutocomplete.php @@ -8,7 +8,7 @@ use Drupal\Core\Controller\ControllerBase; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Drupal\Component\Utility\Tags; -use Drupal\Component\Utility\Unicode; +// use Drupal\Component\Utility\Unicode; use Drupal\search_api\Entity\Index; @@ -24,7 +24,8 @@ class FormAutocomplete extends ControllerBase { // Get the typed string from the URL, if it exists. if ($input = $request->query->get('q')) { $typed_string = Tags::explode($input); - $typed_string = Unicode::strtolower(array_pop($typed_string)); + // $typed_string = Unicode::strtolower(array_pop($typed_string)); + $typed_string = mb_strtolower(array_pop($typed_string)); // \Drupal::logger('materio_sapi')->notice($typed_string); $index = Index::load('autocomplete');