From 54148ab1adb9743b7f97e6f397f3c03fcd96233d Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Wed, 18 Oct 2023 13:25:57 +0100 Subject: [PATCH] chore: tweak --- extend.php | 2 +- src/Elasticsearch/BucketSortAggregation.php | 50 ----------------- src/Elasticsearch/SimpleSearchQuery.php | 59 --------------------- src/Elasticsearch/SumAggregation.php | 43 --------------- 4 files changed, 1 insertion(+), 153 deletions(-) delete mode 100644 src/Elasticsearch/BucketSortAggregation.php delete mode 100644 src/Elasticsearch/SimpleSearchQuery.php delete mode 100644 src/Elasticsearch/SumAggregation.php diff --git a/extend.php b/extend.php index c8479a8..74f2e18 100644 --- a/extend.php +++ b/extend.php @@ -40,7 +40,7 @@ return [ (new Flarum\SearchDriver(Search\ElasticSearchDriver::class)) ->addSearcher(FlarumDiscussion::class, Discussion\DiscussionSearcher::class) ->addFilter(Discussion\DiscussionSearcher::class, Discussion\PrivateFilterMutator::class) -// ->addMutator(Discussion\DiscussionSearcher::class, Discussion\PrivateFilterMutator::mutate(...)) + ->addMutator(Discussion\DiscussionSearcher::class, Discussion\PrivateFilterMutator::mutate(...)) ->setFulltext(Discussion\DiscussionSearcher::class, Discussion\FulltextFilter::class), (new Flarum\SearchIndex()) diff --git a/src/Elasticsearch/BucketSortAggregation.php b/src/Elasticsearch/BucketSortAggregation.php deleted file mode 100644 index 8725286..0000000 --- a/src/Elasticsearch/BucketSortAggregation.php +++ /dev/null @@ -1,50 +0,0 @@ -fields[] = [$field => ['order' => $order]]; - - return $this; - } - - public function size(int $size): self - { - $this->size = $size; - - return $this; - } - - public function payload(): array - { - $parameters = [ - 'sort' => $this->fields, - ]; - - if ($this->size) { - $parameters['size'] = $this->size; - } - - return [ - 'bucket_sort' => $parameters, - ]; - } -} diff --git a/src/Elasticsearch/SimpleSearchQuery.php b/src/Elasticsearch/SimpleSearchQuery.php deleted file mode 100644 index 57d1ab9..0000000 --- a/src/Elasticsearch/SimpleSearchQuery.php +++ /dev/null @@ -1,59 +0,0 @@ -boost = $boost; - - return $this; - } - - public function analyzer(string $analyzer) - { - $this->analyzer = $analyzer; - - return $this; - } - - public function __construct( - protected array $fields, - protected string $value - ) { - } - - public function toArray(): array - { - return [ - 'simple_query_string' => [ - 'query' => $this->value, - 'fields' => $this->fields, - 'analyzer' => $this->analyzer, - 'default_operator' => 'AND', - 'boost' => $this->boost, - ], - ]; - } -} diff --git a/src/Elasticsearch/SumAggregation.php b/src/Elasticsearch/SumAggregation.php deleted file mode 100644 index efe7299..0000000 --- a/src/Elasticsearch/SumAggregation.php +++ /dev/null @@ -1,43 +0,0 @@ -name = $name; - $this->field = $field; - } - - public function payload(): array - { - $parameters = [ - 'field' => $this->field, - ]; - - if ($this->missing) { - $parameters['missing'] = $this->missing; - } - - return [ - 'sum' => $parameters, - ]; - } -}