fuzzy search in thread
This commit is contained in:
parent
3e2f3f9585
commit
5774879331
|
|
@ -377,6 +377,7 @@ class SearchController extends ListDiscussionsController
|
|||
}
|
||||
if ($this->matchWords) {
|
||||
$should->add((new MatchQuery('content', $search))->operator('and')->boost(1.8 * $boost), 'should');
|
||||
$should->add((new MatchQuery('content.autocomplete', $search))->operator('and')->boost(0.30 * $boost), 'should');
|
||||
}
|
||||
|
||||
return $should;
|
||||
|
|
|
|||
|
|
@ -561,8 +561,8 @@ HELP;
|
|||
];
|
||||
}
|
||||
|
||||
protected function mappingProperties(): array
|
||||
{
|
||||
protected function mappingProperties(): array
|
||||
{
|
||||
$language = resolve(SettingsRepositoryInterface::class)->get('blomstra-search.analyzer-language') ?: 'english';
|
||||
|
||||
$titleMapping = [
|
||||
|
|
@ -581,29 +581,42 @@ HELP;
|
|||
];
|
||||
}
|
||||
|
||||
$contentMapping = [
|
||||
'type' => 'text',
|
||||
'analyzer' => 'flarum_analyzer',
|
||||
];
|
||||
|
||||
// Only add the autocomplete subfield for non-CJK languages.
|
||||
if ($language !== 'cjk') {
|
||||
$contentMapping['fields'] = [
|
||||
'autocomplete' => [
|
||||
'type' => 'text',
|
||||
'analyzer' => 'flarum_title_autocomplete',
|
||||
'search_analyzer' => 'flarum_title_search',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'_meta' => ['index_compat_version' => self::INDEX_COMPAT_VERSION],
|
||||
'properties' => [
|
||||
'join_field' => ['type' => 'join', 'relations' => ['discussion' => 'post']],
|
||||
'discussion_id' => ['type' => 'integer'],
|
||||
'content' => ['type' => 'text', 'analyzer' => 'flarum_analyzer'],
|
||||
'content' => $contentMapping,
|
||||
'title' => $titleMapping,
|
||||
'rawId' => ['type' => 'integer'],
|
||||
'created_at' => ['type' => 'date'],
|
||||
'updated_at' => ['type' => 'date'],
|
||||
'is_private' => ['type' => 'boolean'],
|
||||
'is_sticky' => ['type' => 'boolean'],
|
||||
'groups' => ['type' => 'integer'],
|
||||
'tags' => ['type' => 'integer'],
|
||||
'recipient_groups' => ['type' => 'integer'],
|
||||
'recipient_users' => ['type' => 'integer'],
|
||||
'user_id' => ['type' => 'integer'],
|
||||
'groups' => ['type' => 'keyword'],
|
||||
'comment_count' => ['type' => 'integer'],
|
||||
'view_count' => ['type' => 'integer'],
|
||||
'tags' => ['type' => 'keyword'],
|
||||
'is_sticky' => ['type' => 'boolean'],
|
||||
'is_hidden' => ['type' => 'boolean'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Query ES for rawIds already indexed in $targetIndex for the given $joinRelation and ID range.
|
||||
* Retries on transient ES failures (NoNodesAvailableException / other ElasticsearchException)
|
||||
|
|
|
|||
Loading…
Reference in New Issue