fuzzy search in thread
This commit is contained in:
parent
3e2f3f9585
commit
5774879331
|
|
@ -375,9 +375,10 @@ class SearchController extends ListDiscussionsController
|
||||||
if ($this->matchSentences) {
|
if ($this->matchSentences) {
|
||||||
$should->add((new MatchPhraseQuery('content', $search))->boost(2 * $boost), 'should');
|
$should->add((new MatchPhraseQuery('content', $search))->boost(2 * $boost), 'should');
|
||||||
}
|
}
|
||||||
if ($this->matchWords) {
|
if ($this->matchWords) {
|
||||||
$should->add((new MatchQuery('content', $search))->operator('and')->boost(1.8 * $boost), 'should');
|
$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;
|
return $should;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -561,49 +561,62 @@ HELP;
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function mappingProperties(): array
|
protected function mappingProperties(): array
|
||||||
{
|
{
|
||||||
$language = resolve(SettingsRepositoryInterface::class)->get('blomstra-search.analyzer-language') ?: 'english';
|
$language = resolve(SettingsRepositoryInterface::class)->get('blomstra-search.analyzer-language') ?: 'english';
|
||||||
|
|
||||||
$titleMapping = [
|
$titleMapping = [
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'analyzer' => 'flarum_analyzer',
|
'analyzer' => 'flarum_analyzer',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Only add the autocomplete subfield for non-CJK languages.
|
// Only add the autocomplete subfield for non-CJK languages.
|
||||||
if ($language !== 'cjk') {
|
if ($language !== 'cjk') {
|
||||||
$titleMapping['fields'] = [
|
$titleMapping['fields'] = [
|
||||||
'autocomplete' => [
|
'autocomplete' => [
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'analyzer' => 'flarum_title_autocomplete',
|
'analyzer' => 'flarum_title_autocomplete',
|
||||||
'search_analyzer' => 'flarum_title_search',
|
'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'],
|
|
||||||
'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'],
|
|
||||||
'comment_count' => ['type' => 'integer'],
|
|
||||||
'view_count' => ['type' => 'integer'],
|
|
||||||
'is_hidden' => ['type' => 'boolean'],
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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' => $contentMapping,
|
||||||
|
'title' => $titleMapping,
|
||||||
|
'rawId' => ['type' => 'integer'],
|
||||||
|
'created_at' => ['type' => 'date'],
|
||||||
|
'updated_at' => ['type' => 'date'],
|
||||||
|
'is_private' => ['type' => 'boolean'],
|
||||||
|
'user_id' => ['type' => 'integer'],
|
||||||
|
'groups' => ['type' => 'keyword'],
|
||||||
|
'comment_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.
|
* Query ES for rawIds already indexed in $targetIndex for the given $joinRelation and ID range.
|
||||||
* Retries on transient ES failures (NoNodesAvailableException / other ElasticsearchException)
|
* Retries on transient ES failures (NoNodesAvailableException / other ElasticsearchException)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue