Browse Source

fixed the sapi_solr search autocompletewith synonyms

bach 2 years ago
parent
commit
f9a353a32b

+ 24 - 4
config/sync/search_api.index.autocomplete.yml

@@ -5,9 +5,11 @@ dependencies:
   module:
     - search_api_solr
     - taxonomy
+    - synonyms
     - search_api
     - materio_sapi
   config:
+    - field.storage.taxonomy_term.field_synonyms
     - search_api.server.database_search_autocomplete
 third_party_settings:
   search_api_solr:
@@ -15,7 +17,7 @@ third_party_settings:
     commit_before_finalize: false
     commit_after_finalize: false
     multilingual:
-      limit_to_content_language: false
+      limit_to_content_language: true
       include_language_independent: true
     highlighter:
       maxAnalyzedChars: 51200
@@ -43,18 +45,26 @@ third_party_settings:
       maxntp: 2000
       boost: false
       interestingTerms: none
+    term_modifiers:
+      slop: 10000000
+      fuzzy: 2
     advanced:
       index_prefix: ''
       collection: ''
       timezone: ''
-    term_modifiers:
-      slop: 10000000
-      fuzzy: 2
 id: autocomplete
 name: 'autocomplete taxonomy'
 description: ''
 read_only: false
 field_settings:
+  field_synonyms:
+    label: Synonyms
+    datasource_id: 'entity:taxonomy_term'
+    property_path: field_synonyms
+    type: 'solr_text_custom:ngramstring'
+    dependencies:
+      config:
+        - field.storage.taxonomy_term.field_synonyms
   name:
     label: Name
     datasource_id: 'entity:taxonomy_term'
@@ -72,6 +82,14 @@ field_settings:
     dependencies:
       module:
         - taxonomy
+  synonyms:
+    label: 'Synonyms list'
+    datasource_id: 'entity:taxonomy_term'
+    property_path: synonyms
+    type: 'solr_text_custom:ngram'
+    dependencies:
+      module:
+        - synonyms
   tid:
     label: 'Term ID'
     datasource_id: 'entity:taxonomy_term'
@@ -106,6 +124,8 @@ processor_settings:
     boosts:
       'entity:taxonomy_term':
         datasource_boost: !!float 1
+        bundle_boosts:
+          thesaurus: !!float 2
     weights:
       preprocess_index: 0
 tracker_settings:

+ 2 - 2
web/modules/custom/materio_sapi/src/Controller/FormAutocomplete.php

@@ -38,7 +38,7 @@ class FormAutocomplete extends ControllerBase {
 
       // Set fulltext search keywords and fields.
       $query->keys($typed_string);
-      $query->setFulltextFields(['name', 'synonyms']);
+      $query->setFulltextFields(['name', 'field_synonyms']);
 
       // Set additional conditions.
       $query->addCondition('status', 1);
@@ -49,7 +49,7 @@ class FormAutocomplete extends ControllerBase {
       $query->setLanguages([$lang]);
 
       // Do paging.
-      $query->range(0, 10);
+      $query->range(0, 15);
 
       // Add sorting.
       $query->sort('search_api_relevance', 'DESC');

File diff suppressed because it is too large
+ 0 - 0
web/themes/custom/materiotheme/assets/dist/main.css


BIN
web/themes/custom/materiotheme/assets/dist/main.css.gz


File diff suppressed because it is too large
+ 1 - 1
web/themes/custom/materiotheme/assets/dist/report.html


+ 19 - 0
web/themes/custom/materiotheme/assets/styles/main.scss

@@ -733,6 +733,25 @@ header[role="banner"]{
 }
 
 
+ul.ui-menu.ui-widget-content.ui-autocomplete {
+  background-color: rgba(0, 0, 0, 0.6);
+  border-radius: 5px;
+  border: none;
+  padding: 0.3em 0.2em;
+  a.ui-menu-item-wrapper{
+    color: #fff;
+    padding:0.1em 0.1em;
+    display: block;
+    &.ui-state-active{
+      background: none;
+      border: none;
+      color:#fff;
+      background-color: rgba(0, 0, 0, 0.9);
+
+    }
+  }
+}
+
 
 // main
 aside.messages{

Some files were not shown because too many files changed in this diff