Skip to content

Commit e596e82

Browse files
committed
Merge branch '1.3' into 1.x
2 parents 650bfb4 + 483890a commit e596e82

File tree

4 files changed

+96
-62
lines changed

4 files changed

+96
-62
lines changed

config/pimcore/config.yaml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,6 @@ pimcore_generic_data_index:
1717
type: text
1818
analyzer: standard
1919
search_analyzer: generic_data_index_whitespace_analyzer
20-
21-
index_settings:
22-
index:
23-
mapping:
24-
nested_fields:
25-
limit: 200
26-
total_fields:
27-
limit: 100000
28-
number_of_shards: 1
29-
number_of_replicas: 0
30-
max_ngram_diff: 30
31-
max_result_window: 10000
32-
analysis:
33-
analyzer:
34-
generic_data_index_ngram_analyzer:
35-
tokenizer: generic_data_index_ngram_tokenzier
36-
filter:
37-
- lowercase
38-
generic_data_index_whitespace_analyzer:
39-
tokenizer: generic_data_index_whitespace_tokenzier
40-
filter:
41-
- lowercase
42-
generic_data_index_path_analyzer:
43-
tokenizer: generic_data_index_path_tokenizer
44-
normalizer:
45-
generic_data_index_sort_normalizer:
46-
type: custom
47-
filter:
48-
- lowercase
49-
generic_data_index_sort_truncate_normalizer:
50-
type: custom
51-
char_filter:
52-
- generic_data_index_sort_truncate
53-
filter:
54-
- lowercase
55-
tokenizer:
56-
generic_data_index_ngram_tokenzier:
57-
type: ngram
58-
min_gram: 3
59-
max_gram: 25
60-
token_chars: [ letter, digit ]
61-
generic_data_index_whitespace_tokenzier:
62-
type: whitespace
63-
generic_data_index_path_tokenizer:
64-
type: "path_hierarchy"
65-
char_filter:
66-
generic_data_index_sort_truncate:
67-
type: pattern_replace
68-
pattern: ^(.{256})(.*)$
69-
replacement: $1
7020
system_fields_settings:
7121
general:
7222
id:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
index:
2+
mapping:
3+
nested_fields:
4+
limit: 200
5+
total_fields:
6+
limit: 100000
7+
number_of_shards: 1
8+
number_of_replicas: 0
9+
max_ngram_diff: 30
10+
max_result_window: 10000
11+
analysis:
12+
analyzer:
13+
generic_data_index_ngram_analyzer:
14+
tokenizer: generic_data_index_ngram_tokenzier
15+
filter:
16+
- lowercase
17+
generic_data_index_whitespace_analyzer:
18+
tokenizer: generic_data_index_whitespace_tokenzier
19+
filter:
20+
- lowercase
21+
generic_data_index_path_analyzer:
22+
tokenizer: generic_data_index_path_tokenizer
23+
normalizer:
24+
generic_data_index_sort_normalizer:
25+
type: custom
26+
filter:
27+
- lowercase
28+
generic_data_index_sort_truncate_normalizer:
29+
type: custom
30+
char_filter:
31+
- generic_data_index_sort_truncate
32+
filter:
33+
- lowercase
34+
tokenizer:
35+
generic_data_index_ngram_tokenzier:
36+
type: ngram
37+
min_gram: 3
38+
max_gram: 25
39+
token_chars: [ letter, digit ]
40+
generic_data_index_whitespace_tokenzier:
41+
type: whitespace
42+
generic_data_index_path_tokenizer:
43+
type: "path_hierarchy"
44+
char_filter:
45+
generic_data_index_sort_truncate:
46+
type: pattern_replace
47+
pattern: ^(.{256})(.*)$
48+
replacement: $1

doc/02_Configuration/03_Index_Management.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,26 @@ pimcore_generic_data_index:
7171

7272
### Repairing Indices
7373

74-
Sometimes it might be needed to delete and recreate the index (for example if the mapping changed and
75-
cannot be updated).
74+
Sometimes it might be needed to delete and recreate the index from the Pimcore database
75+
(for example if the mapping changed and cannot be updated).
7676

77-
Do this with the index update command and pass -r option.
77+
Do this with the index update command and pass `-r` option (which deletes and recreates the index).
7878
```
7979
# delete index and recreate it
8080
bin/console generic-data-index:update:index -r
8181
```
82+
Without the `-r` option, the index mapping is just updated and all items are added into the queue
83+
for a reindex from the Pimcore database.
84+
8285
8386
### Updating Index Structure for Data Indices
8487
8588
Index mapping is updated automatically e.g. when adding system languages or new fields to the class definition.
8689
Sometimes it might be necessary to update the index structure manually.
8790
88-
Do this with the reindex command.
91+
Do this with the reindex command. This command does native opensearch/elasticsearch re-indexing. So it does not
92+
index data from the database but reindexes data within the search indices.
93+
8994
```
9095
# updates index mapping with native reindexing
9196
bin/console generic-data-index:reindex
@@ -130,4 +135,4 @@ After every class definition update you should run the following command to upda
130135
php bin/console generic-data-index:deployment:reindex
131136
```
132137

133-
This command will update the index structure for all data object classes which were created/updated since the last deployment and reindex all data objects for relevant classes.
138+
This command will update the index structure for all data object classes which were created/updated since the last deployment and reindex all data objects for relevant classes.

src/DependencyInjection/PimcoreGenericDataIndexExtension.php

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,14 @@ public function prepend(ContainerBuilder $container): void
7171
$loader->load('doctrine_migrations.yaml');
7272
}
7373

74-
$filename = __DIR__ . '/../../config/doctrine.yaml';
75-
76-
try {
77-
$config = Yaml::parseFile($filename);
78-
} catch (ParseException $e) {
79-
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $filename), 0, $e);
80-
}
74+
$config = $this->getParsedConfig(__DIR__ . '/../../config/doctrine.yaml');
8175

8276
$container->prependExtensionConfig('doctrine', $config['doctrine']);
8377
}
8478

8579
private function registerIndexServiceParams(ContainerBuilder $container, array $indexSettings): void
8680
{
81+
$indexSettings['index_settings'] = $this->getIndexSettings($indexSettings['index_settings']);
8782
$definition = $container->getDefinition(SearchIndexConfigServiceInterface::class);
8883
$definition->setArgument('$clientType', $indexSettings['client_params']['client_type']);
8984
$definition->setArgument('$indexPrefix', $indexSettings['client_params']['index_prefix']);
@@ -109,6 +104,42 @@ private function registerIndexServiceParams(ContainerBuilder $container, array $
109104
$definition->setArgument('$queueSettings', $indexSettings['queue_settings']);
110105
}
111106

107+
private function getIndexSettings(array $indexSettings): array
108+
{
109+
$defaultIndexSettings = $this->getParsedConfig(
110+
__DIR__ . '/../../config/pimcore/default_index_settings.yaml'
111+
);
112+
113+
return $this->mergeConfig($defaultIndexSettings, $indexSettings);
114+
}
115+
116+
private function mergeConfig(array $default, array $custom): array
117+
{
118+
foreach ($custom as $key => $value) {
119+
$default[$key] = is_array($value) && isset($default[$key]) && is_array($default[$key])
120+
? $this->mergeConfig($default[$key], $value)
121+
: $value;
122+
}
123+
124+
return $default;
125+
}
126+
127+
/**
128+
* @throws InvalidArgumentException
129+
*/
130+
private function getParsedConfig(string $fileLocation): array
131+
{
132+
try {
133+
return Yaml::parseFile($fileLocation);
134+
} catch (ParseException $e) {
135+
throw new InvalidArgumentException(
136+
sprintf('The file "%s" does not contain valid YAML.', $fileLocation),
137+
0,
138+
$e
139+
);
140+
}
141+
}
142+
112143
/**
113144
* @throws InvalidArgumentException
114145
*/

0 commit comments

Comments
 (0)