Skip to content

Commit 16bdcd9

Browse files
authored
Merge pull request #73 from ensi-platform/v8-termvectors
V8 add termvectors
2 parents fbd822a + ff3754c commit 16bdcd9

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ $index->bulk(); // Send bulk request
272272
$index->get(); // Send get request
273273
$index->documentDelete(); // Send documentDelete request
274274
$index->deleteByQuery(); // Send deleteByQuery request
275+
$index->termvectors(); // Send termvectors request
275276

276277
$index->catIndices();
277278
$index->indicesDelete();

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([
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);

src/ElasticQuery.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* @method static Client getClient()
1313
* @method static array|Promise search(string $indexName, array $dsl, string|null $searchType = null)
1414
* @method static array|Promise deleteByQuery(string $indexName, array $dsl)
15+
* @method static array|Promise termvectors(string $indexName, array $dsl)
1516
* @method static array|Promise get(string $indexName, int|string $id)
1617
* @method static array|Promise indicesExists(string $index)
1718
* @method static null|Promise indicesCreate(string $index, array $settings)

0 commit comments

Comments
 (0)