Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/Libraries/Search/BeatmapsetSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function getQuery()
'title_unicode',
'title_unicode.*',
'tags^0.5',
'user_tags',
];

$query = new BoolQuery();
Expand All @@ -61,12 +62,6 @@ public function getQuery()
->should(['term' => ['_id' => ['value' => $this->params->queryString, 'boost' => 100]]])
->should(QueryHelper::queryString($this->params->queryString, $partialMatchFields, 'or', 1 / count($terms)))
->should(QueryHelper::queryString($this->params->queryString, [], 'and'))
->should([
'nested' => [
'path' => 'beatmaps',
'query' => QueryHelper::queryString($this->params->queryString, ['beatmaps.top_tags'], 'or', 0.5 / count($terms)),
],
])
);
}

Expand Down
12 changes: 12 additions & 0 deletions app/Models/Traits/Es/BeatmapsetSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace App\Models\Traits\Es;

use App\Models\Beatmap;
use Ds\Set;

trait BeatmapsetSearch
{
Expand Down Expand Up @@ -54,10 +55,21 @@ protected function getEsFieldValue(string $field)
'beatmaps' => $this->esBeatmapsValues(),
'difficulties' => $this->esDifficultiesValues(),
'id' => $this->getKey(),
'user_tags' => $this->esAllBeatmapTags(),
default => $this->$field,
};
}

private function esAllBeatmapTags(): array
{
$userTags = new Set();
foreach ($this->beatmaps as $beatmap) {
$userTags->add(...$this->esBeatmapTags($beatmap));
}

return $userTags->toArray();
}

private function esBeatmapsValues()
{
$mappings = static::esMappings()['beatmaps']['properties'];
Expand Down
3 changes: 3 additions & 0 deletions config/schemas/beatmapsets.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@
"user_id": {
"type": "long"
},
"user_tags": {
"type": "text"
},
"video": {
"type": "boolean"
}
Expand Down
Loading