From 1a69bcb0f8936c48863bdcccd51250c4d833fb30 Mon Sep 17 00:00:00 2001 From: nanaya Date: Tue, 22 Apr 2025 18:04:35 +0900 Subject: [PATCH] Fix beatmap search simple keyword exclusion still being included --- app/Libraries/Search/BeatmapsetSearch.php | 7 +------ app/Models/Traits/Es/BeatmapsetSearch.php | 12 ++++++++++++ config/schemas/beatmapsets.json | 3 +++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/Libraries/Search/BeatmapsetSearch.php b/app/Libraries/Search/BeatmapsetSearch.php index de3bc6d1f79..be130f58cd1 100644 --- a/app/Libraries/Search/BeatmapsetSearch.php +++ b/app/Libraries/Search/BeatmapsetSearch.php @@ -45,6 +45,7 @@ public function getQuery() 'title_unicode', 'title_unicode.*', 'tags^0.5', + 'user_tags', ]; $query = new BoolQuery(); @@ -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)), - ], - ]) ); } diff --git a/app/Models/Traits/Es/BeatmapsetSearch.php b/app/Models/Traits/Es/BeatmapsetSearch.php index 3026bdd4119..bd2e9073c10 100644 --- a/app/Models/Traits/Es/BeatmapsetSearch.php +++ b/app/Models/Traits/Es/BeatmapsetSearch.php @@ -6,6 +6,7 @@ namespace App\Models\Traits\Es; use App\Models\Beatmap; +use Ds\Set; trait BeatmapsetSearch { @@ -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']; diff --git a/config/schemas/beatmapsets.json b/config/schemas/beatmapsets.json index 26e441d0313..0d4a3061c27 100644 --- a/config/schemas/beatmapsets.json +++ b/config/schemas/beatmapsets.json @@ -243,6 +243,9 @@ "user_id": { "type": "long" }, + "user_tags": { + "type": "text" + }, "video": { "type": "boolean" }