Skip to content

Commit b730019

Browse files
committed
Fix beatmap search simple keyword exclusion still being included
1 parent 7da8655 commit b730019

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

app/Libraries/Search/BeatmapsetSearch.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function getQuery()
4545
'title_unicode',
4646
'title_unicode.*',
4747
'tags^0.5',
48+
'user_tags',
4849
];
4950

5051
$query = new BoolQuery();
@@ -61,12 +62,6 @@ public function getQuery()
6162
->should(['term' => ['_id' => ['value' => $this->params->queryString, 'boost' => 100]]])
6263
->should(QueryHelper::queryString($this->params->queryString, $partialMatchFields, 'or', 1 / count($terms)))
6364
->should(QueryHelper::queryString($this->params->queryString, [], 'and'))
64-
->should([
65-
'nested' => [
66-
'path' => 'beatmaps',
67-
'query' => QueryHelper::queryString($this->params->queryString, ['beatmaps.top_tags'], 'or', 0.5 / count($terms)),
68-
],
69-
])
7065
);
7166
}
7267

app/Models/Traits/Es/BeatmapsetSearch.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace App\Models\Traits\Es;
77

88
use App\Models\Beatmap;
9+
use Ds\Set;
910

1011
trait BeatmapsetSearch
1112
{
@@ -54,10 +55,21 @@ protected function getEsFieldValue(string $field)
5455
'beatmaps' => $this->esBeatmapsValues(),
5556
'difficulties' => $this->esDifficultiesValues(),
5657
'id' => $this->getKey(),
58+
'user_tags' => $this->esAllBeatmapTags(),
5759
default => $this->$field,
5860
};
5961
}
6062

63+
private function esAllBeatmapTags(): array
64+
{
65+
$userTags = new Set();
66+
foreach ($this->beatmaps as $beatmap) {
67+
$userTags->add(...$this->esBeatmapTags($beatmap));
68+
}
69+
70+
return $userTags->toArray();
71+
}
72+
6173
private function esBeatmapsValues()
6274
{
6375
$mappings = static::esMappings()['beatmaps']['properties'];

config/schemas/beatmapsets.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@
243243
"user_id": {
244244
"type": "long"
245245
},
246+
"user_tags": {
247+
"type": "text"
248+
},
246249
"video": {
247250
"type": "boolean"
248251
}

0 commit comments

Comments
 (0)