-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
475: Changes related to the next Meilisearch release (v1.1.0) r=curquiza a=meili-bot Related to this issue: meilisearch/integration-guides#251 This PR: - gathers the changes related to the next Meilisearch release (v1.1.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases). - might eventually contain test failures until the Meilisearch v1.1.0 is out.⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.1.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._ - [x] `csvDelimiter` - [x] `multiSearch` - [ ] release changelog - [x] facetStats Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com> Co-authored-by: Bruno Casali <brunoocasali@gmail.com> Co-authored-by: cvermand <33010418+bidoubiwa@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
435 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Meilisearch\Contracts; | ||
|
||
class SearchQuery | ||
{ | ||
private string $indexUid; | ||
|
||
private string $q; | ||
private array $filter; | ||
private array $attributesToRetrieve; | ||
private array $attributesToCrop; | ||
private ?int $cropLength; | ||
private array $attributesToHighlight; | ||
private string $cropMarker; | ||
private string $highlightPreTag; | ||
private string $highlightPostTag; | ||
private array $facets; | ||
private ?bool $showMatchesPosition; | ||
private array $sort; | ||
private string $matchingStrategy; | ||
private ?int $offset; | ||
private ?int $limit; | ||
private ?int $hitsPerPage; | ||
private ?int $page; | ||
|
||
public function setQuery(string $q): SearchQuery | ||
{ | ||
$this->q = $q; | ||
|
||
return $this; | ||
} | ||
|
||
public function setFilter(array $filter): SearchQuery | ||
{ | ||
$this->filter = $filter; | ||
|
||
return $this; | ||
} | ||
|
||
public function setAttributesToRetrieve(array $attributesToRetrieve): SearchQuery | ||
{ | ||
$this->attributesToRetrieve = $attributesToRetrieve; | ||
|
||
return $this; | ||
} | ||
|
||
public function setAttributesToCrop(array $attributesToCrop): SearchQuery | ||
{ | ||
$this->attributesToCrop = $attributesToCrop; | ||
|
||
return $this; | ||
} | ||
|
||
public function setCropLength(?int $cropLength): SearchQuery | ||
{ | ||
$this->cropLength = $cropLength; | ||
|
||
return $this; | ||
} | ||
|
||
public function setAttributesToHighlight(array $attributesToHighlight): SearchQuery | ||
{ | ||
$this->attributesToHighlight = $attributesToHighlight; | ||
|
||
return $this; | ||
} | ||
|
||
public function setCropMarker(string $cropMarker): SearchQuery | ||
{ | ||
$this->cropMarker = $cropMarker; | ||
|
||
return $this; | ||
} | ||
|
||
public function setHighlightPreTag(string $highlightPreTag): SearchQuery | ||
{ | ||
$this->highlightPreTag = $highlightPreTag; | ||
|
||
return $this; | ||
} | ||
|
||
public function setHighlightPostTag(string $highlightPostTag): SearchQuery | ||
{ | ||
$this->highlightPostTag = $highlightPostTag; | ||
|
||
return $this; | ||
} | ||
|
||
public function setFacets(array $facets): SearchQuery | ||
{ | ||
$this->facets = $facets; | ||
|
||
return $this; | ||
} | ||
|
||
public function setShowMatchesPosition(?bool $showMatchesPosition): SearchQuery | ||
{ | ||
$this->showMatchesPosition = $showMatchesPosition; | ||
|
||
return $this; | ||
} | ||
|
||
public function setSort(array $sort): SearchQuery | ||
{ | ||
$this->sort = $sort; | ||
|
||
return $this; | ||
} | ||
|
||
public function setMatchingStrategy(string $matchingStrategy): SearchQuery | ||
{ | ||
$this->matchingStrategy = $matchingStrategy; | ||
|
||
return $this; | ||
} | ||
|
||
public function setOffset(?int $offset): SearchQuery | ||
{ | ||
$this->offset = $offset; | ||
|
||
return $this; | ||
} | ||
|
||
public function setLimit(?int $limit): SearchQuery | ||
{ | ||
$this->limit = $limit; | ||
|
||
return $this; | ||
} | ||
|
||
public function setHitsPerPage(?int $hitsPerPage): SearchQuery | ||
{ | ||
$this->hitsPerPage = $hitsPerPage; | ||
|
||
return $this; | ||
} | ||
|
||
public function setPage(?int $page): SearchQuery | ||
{ | ||
$this->page = $page; | ||
|
||
return $this; | ||
} | ||
|
||
public function setIndexUid(string $uid): SearchQuery | ||
{ | ||
$this->indexUid = $uid; | ||
|
||
return $this; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return array_filter([ | ||
'indexUid' => $this->indexUid ?? null, | ||
'q' => $this->q ?? null, | ||
'filter' => $this->filter ?? null, | ||
'attributesToRetrieve' => $this->attributesToRetrieve ?? null, | ||
'attributesToCrop' => $this->attributesToCrop ?? null, | ||
'cropLength' => $this->cropLength ?? null, | ||
'attributesToHighlight' => $this->attributesToHighlight ?? null, | ||
'cropMarker' => $this->cropMarker ?? null, | ||
'highlightPreTag' => $this->highlightPreTag ?? null, | ||
'highlightPostTag' => $this->highlightPostTag ?? null, | ||
'facets' => $this->facets ?? null, | ||
'showMatchesPosition' => $this->showMatchesPosition ?? null, | ||
'sort' => $this->sort ?? null, | ||
'matchingStrategy' => $this->matchingStrategy ?? null, | ||
'offset' => $this->offset ?? null, | ||
'limit' => $this->limit ?? null, | ||
'hitsPerPage' => $this->hitsPerPage ?? null, | ||
'page' => $this->page ?? null, | ||
], function ($item) { return null !== $item; }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Meilisearch\Endpoints\Delegates; | ||
|
||
trait HandlesMultiSearch | ||
{ | ||
/** | ||
* @param list<\Meilisearch\Contracts\SearchQuery> $queries | ||
*/ | ||
public function multiSearch(array $queries = []) | ||
{ | ||
$body = []; | ||
|
||
foreach ($queries as $query) { | ||
$body[] = $query->toArray(); | ||
} | ||
|
||
return $this->http->post('/multi-search', ['queries' => $body]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.