Skip to content

Commit

Permalink
much better uuid to id query in opensearch.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbrowncc committed Jun 6, 2024
1 parent 0f8eac1 commit 4bcc032
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions app/Services/StatementSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public function __construct(private readonly Client $client)
}

/**
*
* @param array $filters
* @param array $options
*
* @return Builder
*/
Expand Down Expand Up @@ -618,14 +621,14 @@ public function pushOSAKey($key): void

public function uuidToId(string $uuid): int
{
$uuid = str_replace("-", " ", $uuid); // replace the - with ' '
$query = [
"size" => 1,
"query" => [
"bool" => [
"must" => [
"match" => [
"uuid" => $uuid
]
"match" => [
"uuid" => [
"query" => $uuid,
"operator" => "and"
]
]
],
Expand All @@ -636,6 +639,14 @@ public function uuidToId(string $uuid): int
"excludes" => []
]
];

$result = $this->client->search([
'index' => $this->index_name,
'body' => $query,
]);

return $result['hits']['hits'][0]['_source']['id'] ?? 0;

}

public function PlatformIdPuidToId(int $platform_id, string $puid): int
Expand Down

0 comments on commit 4bcc032

Please sign in to comment.