Skip to content

Commit

Permalink
Clean up some code
Browse files Browse the repository at this point in the history
  • Loading branch information
Firesphere committed Oct 22, 2023
1 parent 8623605 commit 608509c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 61 deletions.
52 changes: 49 additions & 3 deletions src/Indexes/ElasticIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ abstract class ElasticIndex extends CoreIndex
* @var array
*/
protected $clientQuery;
/**
* @var array Fulltext fields
*/
protected $fulltextFields = [];
/**
* @var array Filterable fields
*/
protected $filterFields = [];

/**
* Set-up of core and fields through init
Expand Down Expand Up @@ -112,15 +120,14 @@ public function indexExists(): bool
->asBool();
}

abstract public function getIndexName(): string;

/**
* {@inheritDoc}
* @param ElasticQuery $query
* @return SearchResult
* @throws ClientResponseException
* @throws ServerResponseException
*/
public function doSearch(ElasticQuery $query)
public function doSearch($query)
{
$this->clientQuery = QueryBuilder::buildQuery($query, $this);

Expand All @@ -129,13 +136,52 @@ public function doSearch(ElasticQuery $query)
return new SearchResult($result, $query, $this);
}

/**
* Get current client query array
* @return array
*/
public function getClientQuery(): array
{
return $this->clientQuery;
}

/**
* Gives the option to completely override the client query set
*
* @param array $clientQuery
* @return void
*/
public function setClientQuery(array $clientQuery): void
{
$this->clientQuery = $clientQuery;
}

/**
* Add a single Fulltext field
*
* @param string $fulltextField
* @param array $options
* @return $this
*/
public function addFulltextField($fulltextField, $options = []): self
{
$this->fulltextFields[] = $fulltextField;

return $this;
}

/**
* Add a filterable field
* Compatibility stub for Solr
*
* @param $filterField
* @return $this
*/
public function addFilterField($filterField): self
{
$this->filterFields[] = $filterField;
$this->addFulltextField($filterField);

return $this;
}
}
58 changes: 0 additions & 58 deletions src/Traits/IndexTraits/BaseIndexTrait.php

This file was deleted.

0 comments on commit 608509c

Please sign in to comment.