-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include user tags in Beatmapset search #11763
Changes from all commits
6602a30
cc56230
1ac3df6
80f4630
8e06124
8263544
a403519
0a36d89
0ce6d86
8eaabb0
cb8be2a
1cc6840
7680e04
91c5061
572b76f
8d8a76f
390d752
d8b38f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Jobs; | ||
|
||
use Illuminate\Contracts\Queue\ShouldBeUnique; | ||
|
||
class EsDocumentUnique extends EsDocument implements ShouldBeUnique | ||
{ | ||
public int $uniqueFor = 600; | ||
|
||
public function uniqueId(): string | ||
{ | ||
return "{$this->modelMeta['class']}-{$this->modelMeta['id']}"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
use App\Models\Beatmapset; | ||
use App\Models\Follow; | ||
use App\Models\Solo; | ||
use App\Models\Tag; | ||
use App\Models\User; | ||
use Ds\Set; | ||
|
||
|
@@ -60,6 +61,12 @@ 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)), | ||
], | ||
]) | ||
); | ||
} | ||
|
||
|
@@ -82,6 +89,7 @@ public function getQuery() | |
$this->addPlayedFilter($query, $nested); | ||
$this->addRankFilter($nested); | ||
$this->addRecommendedFilter($nested); | ||
$this->addTagsFilter($nested); | ||
|
||
$this->addSimpleFilters($query, $nested); | ||
$this->addCreatorFilter($query, $nested); | ||
|
@@ -398,6 +406,25 @@ private function addTextFilter(BoolQuery $query, string $paramField, array $fiel | |
$query->must($subQuery); | ||
} | ||
|
||
private function addTagsFilter(BoolQuery $query): void | ||
{ | ||
if ($this->params->tags === null) { | ||
return; | ||
} | ||
|
||
$tagSet = new Set(array_map('mb_strtolower', $this->params->tags)); | ||
$tags = Tag::whereIn('name', $this->params->tags)->limit(10)->pluck('name'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the limit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so you can't put hundreds of tags in; the limit should be in the parser but I didn't decide whether it should be throwing or how the UI is supposed to handle it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, the remaining hundreds of tags will still be looked up anyway... presumably with slower text query instead of keyword |
||
$tagSet->remove(...$tags->map(fn ($name) => mb_strtolower($name))->toArray()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
foreach ($tagSet as $tag) { | ||
$query->filter(QueryHelper::queryString($tag, ['beatmaps.top_tags'], 'and')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apparently searching for also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well that's partly a parsing issue unless we want to start going There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
foreach ($tags as $tag) { | ||
$query->filter(['term' => ['beatmaps.top_tags.raw' => $tag]]); | ||
} | ||
} | ||
|
||
private function getPlayedBeatmapIds(?array $rank = null) | ||
{ | ||
$query = Solo\Score | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be also shared with the beatmap specific
$nested
query down below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scoring and matching of the query string is not the same in the other nested filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this match tag that isn't part of beatmap specific field match? searching by this and difficulty for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Searching for
potato foo difficulty=mayday
returns beatmapsets withmayday
difficulty with relevance score according to how the fields in the query matchpotato foo