Skip to content

Commit

Permalink
add missing search client adapter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmzig committed Nov 7, 2024
1 parent 5a17730 commit a567911
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": "^8.0",
"php": "^8.1",
"pimcore/pimcore": "^11.x-dev",
"opensearch-project/opensearch-php": "^2.2.0"
},
Expand Down
98 changes: 98 additions & 0 deletions src/SearchClient/SearchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ public function get(array $params): array
}
}

/**
* @throws ClientException
*/
public function exists(array $params): bool
{
try {
return $this->client->exists($params);
} catch (Exception $exception) {
throw new ClientException(
sprintf('Failed to check if data exists: %s', $exception->getMessage())
);
}
}

/**
* @throws ClientException
*/
Expand All @@ -91,6 +105,20 @@ public function count(array $params): array
}
}

/**
* @throws ClientException
*/
public function index(array $params): array
{
try {
return $this->client->index($params);
} catch (Exception $exception) {
throw new ClientException(
sprintf('Index operation failed: %s', $exception->getMessage())
);
}
}

/**
* @throws ClientException
*/
Expand All @@ -105,6 +133,20 @@ public function bulk(array $params): array
}
}

/**
* @throws ClientException
*/
public function delete(array $params): array
{
try {
return $this->client->delete($params);
} catch (Exception $exception) {
throw new ClientException(
sprintf('Delete operation failed: %s', $exception->getMessage())
);
}
}

/**
* @throws ClientException
*/
Expand Down Expand Up @@ -147,6 +189,48 @@ public function createIndex(array $params): array
}
}

/**
* @throws ClientException
*/
public function openIndex(array $params): array
{
try {
return $this->client->indices()->open($params);
} catch (Exception $exception) {
throw new ClientException(
sprintf('Failed to open index: %s', $exception->getMessage())
);
}
}

/**
* @throws ClientException
*/
public function closeIndex(array $params): array
{
try {
return $this->client->indices()->close($params);
} catch (Exception $exception) {
throw new ClientException(
sprintf('Failed to close index: %s', $exception->getMessage())
);
}
}

/**
* @throws ClientException
*/
public function getAllIndices(array $params): array
{
try {
return $this->client->cat()->indices($params);
} catch (Exception $exception) {
throw new ClientException(
sprintf('Failed to get all indices: %s', $exception->getMessage())
);
}
}

/**
* @throws ClientException
*/
Expand Down Expand Up @@ -315,6 +399,20 @@ public function getIndexMapping(array $params): array
}
}

/**
* @throws ClientException
*/
public function getIndexSettings(array $params): array
{
try {
return $this->client->indices()->getSettings($params);
} catch (Exception $exception) {
throw new ClientException(
sprintf('Failed to get index settings: %s', $exception->getMessage())
);
}
}

/**
* @throws ClientException
*/
Expand Down

0 comments on commit a567911

Please sign in to comment.