Skip to content

Commit b09dd46

Browse files
committed
replacing some usages of simple_query_string with match
1 parent 3f2d4e0 commit b09dd46

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

app/Libraries/Search/BeatmapsetSearch.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,16 @@ private function addCreatorFilter(): void
251251
private function addDifficultyFilter()
252252
{
253253
if ($this->includes->difficulty !== null) {
254-
$this->nested->must(['match' => ['beatmaps.version' => ['query' => $this->includes->difficulty, 'operator' => 'and']]]);
254+
$params = static::isQuoted($this->includes->difficulty)
255+
? ['match_phrase' => ['beatmaps.version' => $this->includes->difficulty]]
256+
: ['match' => ['beatmaps.version' => ['query' => $this->includes->difficulty, 'operator' => 'and']]];
257+
$this->nested->must($params);
255258
}
256259

260+
// difficulty excludes if any single beatmap matches since requiring all the difficulties to have the matching phrase would be weird.
257261
if ($this->excludes->difficulty !== null) {
258-
$this->nestedMustNot->should(['match' => ['beatmaps.version' => ['query' => $this->excludes->difficulty, 'operator' => 'or']]]);
262+
$matcher = static::isQuoted($this->excludes->difficulty) ? 'match_phrase' : 'match';
263+
$this->nestedMustNot->should([$matcher => ['beatmaps.version' => $this->excludes->difficulty]]);
259264
}
260265
}
261266

0 commit comments

Comments
 (0)