Skip to content

Commit

Permalink
Merge pull request #759 from afoucret/fix-sku-relevance
Browse files Browse the repository at this point in the history
Fix sku releavance (#628).
  • Loading branch information
afoucret authored Feb 16, 2018
2 parents dc4c57d + df374e7 commit b321cc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<field name="type_id" type="string" />
<field name="sku" type="string">
<isSearchable>1</isSearchable>
<isUsedForSortBy>1</isUsedForSortBy>
<isUsedInSpellcheck>1</isUsedInSpellcheck>
<defaultSearchAnalyzer>whitespace</defaultSearchAnalyzer>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,17 @@ private function getWeightedSearchQuery(ContainerConfigurationInterface $contain
$phraseMatchBoost = $relevanceConfig->getPhraseMatchBoost();
$defaultSearchField = MappingInterface::DEFAULT_SEARCH_FIELD;
$searchableFieldFilter = $this->fieldFilters['searchableFieldFilter'];
$sortableAnalyzer = FieldInterface::ANALYZER_SORTABLE;
$phraseAnalyzer = FieldInterface::ANALYZER_WHITESPACE;

$phraseAnalyzer = FieldInterface::ANALYZER_WHITESPACE;
if (is_string($queryText) && str_word_count($queryText) > 1) {
$phraseAnalyzer = FieldInterface::ANALYZER_SHINGLE;
}

$searchFields = array_merge(
$this->getWeightedFields($containerConfig, null, $searchableFieldFilter, $defaultSearchField),
$this->getWeightedFields($containerConfig, $phraseAnalyzer, $searchableFieldFilter, $defaultSearchField, $phraseMatchBoost)
$this->getWeightedFields($containerConfig, $phraseAnalyzer, $searchableFieldFilter, $defaultSearchField, $phraseMatchBoost),
$this->getWeightedFields($containerConfig, $sortableAnalyzer, $searchableFieldFilter, null, 2 * $phraseMatchBoost)
);

$queryParams = [
Expand Down

0 comments on commit b321cc2

Please sign in to comment.