Skip to content

Commit be7c0f0

Browse files
authored
Add ignore_above configs to keyword fields to avoid max_bytes_length_exceeded_exception (#176)
1 parent 9111d4d commit be7c0f0

File tree

6 files changed

+10
-0
lines changed

6 files changed

+10
-0
lines changed

config/pimcore/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ pimcore_generic_data_index:
197197
type: float
198198
text:
199199
type: keyword
200+
ignore_above: 256
200201
fields:
201202
analyzed_ngram:
202203
type: text

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ private function buildSystemFieldsSettingsNode(string $name): ArrayNodeDefinitio
157157
->end()
158158
->scalarNode('analyzer')
159159
->end()
160+
->scalarNode('ignore_above')
161+
->end()
160162
->append($this->buildVariableNode('properties'))
161163
->append($this->buildVariableNode('fields'))
162164
->end()

src/SearchIndexAdapter/OpenSearch/Asset/FieldDefinitionAdapter/KeywordAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function getIndexMapping(): array
2929
{
3030
return [
3131
'type' => AttributeType::KEYWORD->value,
32+
'ignore_above' => 10000,
3233
];
3334
}
3435

src/SearchIndexAdapter/OpenSearch/IndexMappingService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function getMappingForTextKeyword(array $attributes): array
6363
[
6464
'keyword' => [
6565
'type' => AttributeType::KEYWORD->value,
66+
'ignore_above' => 1024,
6667
],
6768
]
6869
),

tests/Unit/SearchIndexAdapter/Asset/FieldDefinitionAdapter/KeywordAdapterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function testGetOpenSearchMapping(): void
3838
$mapping = $adapter->getIndexMapping();
3939
$this->assertSame([
4040
'type' => 'keyword',
41+
'ignore_above' => 10000,
4142
], $mapping);
4243
}
4344

tests/Unit/SearchIndexAdapter/OpenSearch/IndexMappingServiceTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function testGetMappingForTextKeywordWithoutArguments(): void
131131
'fields' => [
132132
'keyword' => [
133133
'type' => 'keyword',
134+
'ignore_above' => 1024,
134135
],
135136
],
136137
],
@@ -167,6 +168,7 @@ public function testGetMappingForTextKeywordWithArguments(): void
167168
],
168169
'keyword' => [
169170
'type' => 'keyword',
171+
'ignore_above' => 1024,
170172
],
171173
],
172174
],
@@ -211,6 +213,7 @@ public function testGetMappingForAdvancedImage(): void
211213
'fields' => [
212214
'keyword' => [
213215
'type' => 'keyword',
216+
'ignore_above' => 1024,
214217
],
215218
],
216219
],
@@ -239,6 +242,7 @@ public function testGetMappingForAdvancedImage(): void
239242
'fields' => [
240243
'keyword' => [
241244
'type' => 'keyword',
245+
'ignore_above' => 1024,
242246
],
243247
],
244248
],

0 commit comments

Comments
 (0)