Skip to content

Commit 3aa35fb

Browse files
committed
V8 add termvectors
1 parent fbd822a commit 3aa35fb

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

src/Concerns/InteractsWithIndex.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public function deleteByQuery(array $dsl): array|Promise
4242
return $this->resolveClient()->deleteByQuery($this->indexName(), $dsl);
4343
}
4444

45+
/**
46+
* @see SearchIndex::termvectors()
47+
*/
48+
public function termvectors(array $dsl): array|Promise
49+
{
50+
return $this->resolveClient()->termvectors($this->indexName(), $dsl);
51+
}
52+
4553
public function isCreated(): bool|Promise
4654
{
4755
return $this->resolveClient()->indicesExists($this->indexName());

src/Contracts/MatchOptions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ public function __construct(private array $options = [])
1414
public static function make(
1515
?string $operator = null,
1616
?string $fuzziness = null,
17-
?string $minimumShouldMatch = null
17+
?string $minimumShouldMatch = null,
18+
?string $analyzer = null
1819
): static {
1920
Assert::nullOrOneOf($operator, ['or', 'and']);
2021

2122
return new static(array_filter([
2223
'operator' => $operator,
2324
'fuzziness' => $fuzziness,
2425
'minimum_should_match' => $minimumShouldMatch,
26+
'analyzer' => $analyzer,
2527
]));
2628
}
2729

src/Contracts/SearchIndex.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,12 @@ public function search(array $dsl, ?string $searchType = null): array|Promise;
2929
* @return array|Promise
3030
*/
3131
public function deleteByQuery(array $dsl): array|Promise;
32+
33+
/**
34+
* Retrieves information and statistics for terms in the fields of a particular document.
35+
*
36+
* @param array $dsl
37+
* @return array|Promise
38+
*/
39+
public function termvectors(array $dsl): array|Promise;
3240
}

src/ElasticClient.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ public function search(string $indexName, array $dsl, ?string $searchType = null
3737
);
3838
}
3939

40+
public function termvectors(string $indexName, array $dsl): array|Promise
41+
{
42+
$this->queryLog?->log($indexName, $dsl);
43+
44+
return Response::array(
45+
$this->client->termvectors(array_filter([
46+
'index' => $indexName,
47+
'body' => $dsl,
48+
]))
49+
);
50+
}
51+
4052
public function deleteByQuery(string $indexName, array $dsl): array|Promise
4153
{
4254
$this->queryLog?->log($indexName, $dsl);

0 commit comments

Comments
 (0)