Skip to content

Commit 677cab0

Browse files
committed
Make mapping and settings builders explicit
1 parent 5310466 commit 677cab0

9 files changed

Lines changed: 1055 additions & 196 deletions

File tree

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,52 @@ $mapping = (new Mapping)
4444
$settings = (new Settings)->index([
4545
'number_of_shards' => 1,
4646
'number_of_replicas' => 0,
47+
'refresh_interval' => '1s',
4748
]);
4849

4950
$indices->create(new IndexBlueprint('books', $mapping, $settings));
5051
```
5152

53+
Use `field()` for less common, custom, or newer OpenSearch field types:
54+
55+
```php
56+
$mapping = (new Mapping)->field('embedding', 'custom_vector', [
57+
'dimension' => 1536,
58+
]);
59+
```
60+
61+
Settings include top-level setters for common OpenSearch settings groups:
62+
63+
```php
64+
$settings = (new Settings)
65+
->index([
66+
'number_of_shards' => 1,
67+
'number_of_replicas' => 0,
68+
])
69+
->analysis([
70+
'analyzer' => [
71+
'content' => [
72+
'type' => 'custom',
73+
'tokenizer' => 'whitespace',
74+
],
75+
],
76+
])
77+
->similarity([
78+
'default' => [
79+
'type' => 'BM25',
80+
],
81+
]);
82+
```
83+
84+
Use `set()` for top-level settings groups that do not have a dedicated method:
85+
86+
```php
87+
$settings = (new Settings)
88+
->set('custom_group', [
89+
'enabled' => true,
90+
]);
91+
```
92+
5293
## Indexing Documents
5394

5495
Documents contain the OpenSearch document ID and source payload:

0 commit comments

Comments
 (0)