Skip to content

Commit

Permalink
Add support for query suggestions (aka "did you mean") (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispenny authored Aug 21, 2024
1 parent ed2ee21 commit c9b9f5c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 2 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ SilverStripe\Core\Injector\Injector:
class: SilverStripe\DiscovererBifrost\Service\Requests\Search
Elastic\EnterpriseSearch\AppSearch\Request\LogClickthrough:
class: SilverStripe\DiscovererBifrost\Service\Requests\ClickPost
Elastic\EnterpriseSearch\AppSearch\Request\QuerySuggestion:
class: SilverStripe\DiscovererBifrost\Service\Requests\QuerySuggestion

SilverStripe\DiscovererElasticEnterprise\Service\SearchServiceAdaptor:
prefix_env_var: 'BIFROST_ENGINE_PREFIX'
12 changes: 1 addition & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,13 @@
"require": {
"php": "^8.1",
"silverstripe/framework": "^5",
"silverstripe/silverstripe-discoverer-elastic-enterprise": "^1",
"silverstripe/silverstripe-discoverer-elastic-enterprise": "^1.1",
"guzzlehttp/guzzle": "^7.5"
},
"require-dev": {
"phpunit/phpunit": "^9.6.19",
"slevomat/coding-standard": "^8.8"
},
"repositories": [
{
"type": "vcs",
"url": "[email protected]:silverstripeltd/silverstripe-discoverer.git"
},
{
"type": "vcs",
"url": "[email protected]:silverstripeltd/silverstripe-discoverer-elastic-enterprise.git"
}
],
"autoload": {
"psr-4": {
"SilverStripe\\DiscovererBifrost\\": "src/",
Expand Down
18 changes: 18 additions & 0 deletions src/Service/Requests/QuerySuggestion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace SilverStripe\DiscovererBifrost\Service\Requests;

use Elastic\EnterpriseSearch\AppSearch\Request\QuerySuggestion as AppSearchQuerySuggestion;
use Elastic\EnterpriseSearch\AppSearch\Schema\QuerySuggestionRequest;

class QuerySuggestion extends AppSearchQuerySuggestion
{

public function __construct(string $engineName, ?QuerySuggestionRequest $query_suggestion_request = null)
{
parent::__construct($engineName, $query_suggestion_request);

$this->path = sprintf('/api/v1/%s/query_suggestion', $engineName);
}

}

0 comments on commit c9b9f5c

Please sign in to comment.