fixed the sapi_solr search autocompletewith synonyms

This commit is contained in:
Bachir Soussi Chiadmi 2021-07-28 22:11:46 +02:00
parent b67c88dfa7
commit f9a353a32b
6 changed files with 48 additions and 9 deletions

View File

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

View File

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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 // main
aside.messages{ aside.messages{