Skip to content

Commit 148bd44

Browse files
Merge pull request #319 from daniellienert/task/rename-fields
WIP: !!! TASK: Rename fields to beats convention
2 parents 3666a83 + 7e8e234 commit 148bd44

15 files changed

+173
-86
lines changed

Classes/Command/NodeIndexCommandController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ private function applyMapping(): void
557557
/** @var Mapping $mapping */
558558
$mapping->apply();
559559
}
560-
$this->logger->info('+ Updated Mapping.', LogEnvironment::fromMethodName(__METHOD__));
561560
}
562561

563562
private function outputMemoryUsage(): void

Classes/Command/SearchCommandController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function viewNodeCommand(string $identifier, ?string $dimensions = null,
113113

114114
$queryBuilder = new ElasticSearchQueryBuilder();
115115
$queryBuilder->query($context->getRootNode());
116-
$queryBuilder->exactMatch('__identifier', $identifier);
116+
$queryBuilder->exactMatch('neos_node_identifier', $identifier);
117117

118118
$queryBuilder->getRequest()->setValueByPath('_source', []);
119119

Classes/Driver/AbstractQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public function highlight($fragmentSize, int $fragmentCount = null): void
188188
} else {
189189
$this->request['highlight'] = [
190190
'fields' => [
191-
'__fulltext*' => [
191+
'neos_fulltext*' => [
192192
'fragment_size' => $fragmentSize,
193193
'no_match_size' => $fragmentSize,
194194
'number_of_fragments' => $fragmentCount

Classes/Driver/Version6/IndexerDriver.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class IndexerDriver extends AbstractIndexerDriver implements IndexerDriverInterf
3535
public function document(string $indexName, NodeInterface $node, ElasticSearchDocument $document, array $documentData): array
3636
{
3737
if ($this->isFulltextRoot($node)) {
38-
// for fulltext root documents, we need to preserve the "__fulltext" field. That's why we use the
38+
// for fulltext root documents, we need to preserve the "neos_fulltext" field. That's why we use the
3939
// "update" API instead of the "index" API, with a custom script internally; as we
40-
// shall not delete the "__fulltext" part of the document if it has any.
40+
// shall not delete the "neos_fulltext" part of the document if it has any.
4141
return [
4242
[
4343
'update' => [
@@ -52,11 +52,11 @@ public function document(string $indexName, NodeInterface $node, ElasticSearchDo
5252
'script' => [
5353
'lang' => 'painless',
5454
'source' => '
55-
HashMap fulltext = (ctx._source.containsKey("__fulltext") && ctx._source.__fulltext instanceof Map ? ctx._source.__fulltext : new HashMap());
56-
HashMap fulltextParts = (ctx._source.containsKey("__fulltextParts") && ctx._source.__fulltextParts instanceof Map ? ctx._source.__fulltextParts : new HashMap());
55+
HashMap fulltext = (ctx._source.containsKey("neos_fulltext") && ctx._source.neos_fulltext instanceof Map ? ctx._source.neos_fulltext : new HashMap());
56+
HashMap fulltextParts = (ctx._source.containsKey("neos_fulltext_parts") && ctx._source.neos_fulltext_parts instanceof Map ? ctx._source.neos_fulltext_parts : new HashMap());
5757
ctx._source = params.newData;
58-
ctx._source.__fulltext = fulltext;
59-
ctx._source.__fulltextParts = fulltextParts',
58+
ctx._source.neos_fulltext = fulltext;
59+
ctx._source.neos_fulltext_parts = fulltextParts',
6060
'params' => [
6161
'newData' => $documentData
6262
]
@@ -117,32 +117,32 @@ public function fulltext(NodeInterface $node, array $fulltextIndexOfNode, string
117117
],
118118
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.html
119119
[
120-
// first, update the __fulltextParts, then re-generate the __fulltext from all __fulltextParts
120+
// first, update the neos_fulltext_parts, then re-generate the neos_fulltext from all neos_fulltext_parts
121121
'script' => [
122122
'lang' => 'painless',
123123
'source' => '
124-
ctx._source.__fulltext = new HashMap();
125-
if (!ctx._source.containsKey("__fulltextParts") || !(ctx._source.__fulltextParts instanceof Map)) {
126-
ctx._source.__fulltextParts = new HashMap();
124+
ctx._source.neos_fulltext = new HashMap();
125+
if (!ctx._source.containsKey("neos_fulltext_parts") || !(ctx._source.neos_fulltext_parts instanceof Map)) {
126+
ctx._source.neos_fulltext_parts = new HashMap();
127127
}
128128
129129
if (params.nodeIsRemoved || params.nodeIsHidden || params.fulltext.size() == 0) {
130-
if (ctx._source.__fulltextParts.containsKey(params.identifier)) {
131-
ctx._source.__fulltextParts.remove(params.identifier);
130+
if (ctx._source.neos_fulltext_parts.containsKey(params.identifier)) {
131+
ctx._source.neos_fulltext_parts.remove(params.identifier);
132132
}
133133
} else {
134-
ctx._source.__fulltextParts.put(params.identifier, params.fulltext);
134+
ctx._source.neos_fulltext_parts.put(params.identifier, params.fulltext);
135135
}
136136
137-
for (fulltextPart in ctx._source.__fulltextParts.entrySet()) {
137+
for (fulltextPart in ctx._source.neos_fulltext_parts.entrySet()) {
138138
for (entry in fulltextPart.getValue().entrySet()) {
139139
def value = "";
140-
if (ctx._source.__fulltext.containsKey(entry.getKey())) {
141-
value = ctx._source.__fulltext[entry.getKey()] + " " + entry.getValue().trim();
140+
if (ctx._source.neos_fulltext.containsKey(entry.getKey())) {
141+
value = ctx._source.neos_fulltext[entry.getKey()] + " " + entry.getValue().trim();
142142
} else {
143143
value = entry.getValue().trim();
144144
}
145-
ctx._source.__fulltext[entry.getKey()] = value;
145+
ctx._source.neos_fulltext[entry.getKey()] = value;
146146
}
147147
}',
148148
'params' => [
@@ -153,8 +153,8 @@ public function fulltext(NodeInterface $node, array $fulltextIndexOfNode, string
153153
],
154154
],
155155
'upsert' => [
156-
'__fulltext' => $fulltextIndexOfNode,
157-
'__fulltextParts' => $upsertFulltextParts
156+
'neos_fulltext' => $fulltextIndexOfNode,
157+
'neos_fulltext_parts' => $upsertFulltextParts
158158
]
159159
]
160160
];

Classes/Eel/ElasticSearchQueryBuilder.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ class ElasticSearchQueryBuilder implements QueryBuilderInterface, ProtectedConte
124124
*/
125125
public function nodeType($nodeType)
126126
{
127-
// on indexing, __typeAndSupertypes contains the typename itself and all supertypes, so that's why we can
127+
// on indexing, neos_type_and_supertypes contains the typename itself and all supertypes, so that's why we can
128128
// use a simple term filter here.
129129

130130
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
131-
return $this->queryFilter('term', ['__typeAndSupertypes' => $nodeType]);
131+
return $this->queryFilter('term', ['neos_type_and_supertypes' => $nodeType]);
132132
}
133133

134134
/**
@@ -466,7 +466,7 @@ public function aggregation(string $name, array $aggregationDefinition, string $
466466
* @param string $name
467467
* @return ElasticSearchQueryBuilder
468468
*/
469-
public function termSuggestions(string $text, string $field = '__fulltext.text', string $name = 'suggestions'): ElasticSearchQueryBuilder
469+
public function termSuggestions(string $text, string $field = 'neos_fulltext.text', string $name = 'suggestions'): ElasticSearchQueryBuilder
470470
{
471471
$suggestionDefinition = [
472472
'text' => $text,
@@ -750,7 +750,7 @@ public function moreLikeThis(array $like, array $fields = [], array $options = [
750750
$like = is_array($like) ? $like : [$like];
751751

752752
$getDocumentDefinitionByNode = function (QueryInterface $request, NodeInterface $node): array {
753-
$request->queryFilter('term', ['__identifier' => $node->getIdentifier()]);
753+
$request->queryFilter('term', ['neos_node_identifier' => $node->getIdentifier()]);
754754
$response = $this->elasticSearchClient->getIndex()->request('GET', '/_search', [], $request->toArray())->getTreatedContent();
755755
$respondedDocuments = Arrays::getValueByPath($response, 'hits.hits');
756756
if (count($respondedDocuments) === 0) {
@@ -801,24 +801,24 @@ public function query(NodeInterface $contextNode): ElasticSearchQueryBuilder
801801
{
802802
$this->elasticSearchClient->setContextNode($contextNode);
803803

804-
// on indexing, the __parentPath is tokenized to contain ALL parent path parts,
804+
// on indexing, the neos_parent_path is tokenized to contain ALL parent path parts,
805805
// e.g. /foo, /foo/bar/, /foo/bar/baz; to speed up matching.. That's why we use a simple "term" filter here.
806806
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
807807
// another term filter against the path allows the context node itself to be found
808808
$this->queryFilter('bool', [
809809
'should' => [
810810
[
811-
'term' => ['__parentPath' => $contextNode->getPath()]
811+
'term' => ['neos_parent_path' => $contextNode->getPath()]
812812
],
813813
[
814-
'term' => ['__path' => $contextNode->getPath()]
814+
'term' => ['neos_path' => $contextNode->getPath()]
815815
]
816816
]
817817
]);
818818

819819
//
820820
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
821-
$this->queryFilter('terms', ['__workspace' => array_unique(['live', $contextNode->getContext()->getWorkspace()->getName()])]);
821+
$this->queryFilter('terms', ['neos_workspace' => array_unique(['live', $contextNode->getContext()->getWorkspace()->getName()])]);
822822

823823
return $this;
824824
}
@@ -873,7 +873,7 @@ protected function convertHitsToNodes(array $hits): array
873873
* we might be able to use https://github.com/elasticsearch/elasticsearch/issues/3300 as soon as it is merged.
874874
*/
875875
foreach ($hits as $hit) {
876-
$nodePath = $hit[isset($hit['fields']['__path']) ? 'fields' : '_source']['__path'];
876+
$nodePath = $hit[isset($hit['fields']['neos_path']) ? 'fields' : '_source']['neos_path'];
877877
if (is_array($nodePath)) {
878878
$nodePath = current($nodePath);
879879
}
@@ -908,8 +908,8 @@ protected function convertHitsToNodes(array $hits): array
908908
public function cacheLifetime(): int
909909
{
910910
$minTimestamps = array_filter([
911-
$this->getNearestFutureDate('_hiddenBeforeDateTime'),
912-
$this->getNearestFutureDate('_hiddenAfterDateTime')
911+
$this->getNearestFutureDate('neos_hidden_before_datetime'),
912+
$this->getNearestFutureDate('neos_hidden_after_datetime')
913913
], function ($value) {
914914
return $value != 0;
915915
});
@@ -957,7 +957,7 @@ protected function getNearestFutureDate(string $dateField): int
957957

958958
/* Remove exclusion of not yet visible nodes
959959
- range:
960-
_hiddenBeforeDateTime:
960+
neos_hidden_before_datetime:
961961
gt: now
962962
*/
963963
unset($mustNot[1]);

Classes/Indexer/NodeIndexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null): voi
279279

280280
$documentData = $document->getData();
281281
if ($targetWorkspaceName !== null) {
282-
$documentData['__workspace'] = $targetWorkspaceName;
282+
$documentData['neos_workspace'] = $targetWorkspaceName;
283283
}
284284

285285
$this->toBulkRequest($node, $this->indexerDriver->document($this->getIndexName(), $node, $document, $documentData));

Configuration/NodeTypes.Override.Document.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
title:
1111
search:
1212
fulltextExtractor: ${Indexing.extractInto('h1', value)}
13-
'__fulltextParts':
13+
'neos_fulltext_parts':
1414
search:
1515
elasticSearchMapping:
1616
type: object
1717
enabled: false
1818
indexing: ''
19-
'__fulltext':
19+
'neos_fulltext':
2020
search:
2121
indexing: ''
2222
elasticSearchMapping:
@@ -36,6 +36,11 @@
3636
type: text
3737
'text':
3838
type: text
39-
'_hiddenInIndex':
39+
'neos_hidden_in_index':
4040
search:
4141
indexing: '${node.hiddenInIndex}'
42+
43+
# deliberately don't map or index this
44+
'_hiddenInIndex':
45+
search:
46+
indexing: false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'Neos.Neos:Hidable':
22
properties:
3-
'_hidden':
3+
'neos_hidden':
44
search:
55
indexing: '${node.hidden}'

Configuration/NodeTypes.Override.Node.yaml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,95 @@
33
fulltext:
44
enable: true
55
properties:
6-
'__identifier':
6+
'neos_node_identifier':
77
search:
88
elasticSearchMapping:
99
type: keyword
1010
indexing: '${node.identifier}'
1111

12-
'__workspace':
12+
'neos_workspace':
1313
search:
1414
elasticSearchMapping:
1515
type: keyword
1616
indexing: '${node.context.workspace.name}'
1717

18-
'__path':
18+
'neos_path':
1919
search:
2020
elasticSearchMapping:
2121
type: keyword
2222
indexing: '${node.path}'
2323

24-
'__parentPath':
24+
'neos_parent_path':
2525
search:
2626
elasticSearchMapping:
2727
type: keyword
2828
# we index *all* parent paths as separate tokens to allow for efficient searching without a prefix query
2929
indexing: '${Indexing.buildAllPathPrefixes(node.parentPath)}'
3030

31-
'__sortIndex':
31+
'neos_sort_index':
3232
search:
3333
elasticSearchMapping:
3434
type: integer
3535
indexing: '${node.index}'
3636

37-
'_removed':
38-
search:
39-
elasticSearchMapping: '' # deliberately don't map or index this
40-
indexing: ''
41-
4237
# we index the node type INCLUDING ALL SUPERTYPES
43-
'__typeAndSupertypes':
38+
'neos_type_and_supertypes':
4439
search:
4540
elasticSearchMapping:
4641
type: keyword
4742
indexing: '${Indexing.extractNodeTypeNamesAndSupertypes(node.nodeType)}'
4843

49-
'_lastModificationDateTime':
44+
'neos_last_modification_date_time':
5045
search:
5146
elasticSearchMapping:
5247
type: date
5348
format: 'date_time_no_millis'
5449
indexing: '${(node.lastModificationDateTime ? Date.format(node.lastModificationDateTime, "Y-m-d\TH:i:sP") : null)}'
5550

56-
'_lastPublicationDateTime':
51+
'neos_last_publication_date_time':
5752
search:
5853
elasticSearchMapping:
5954
type: date
6055
format: 'date_time_no_millis'
6156
indexing: '${(node.lastPublicationDateTime ? Date.format(node.lastPublicationDateTime, "Y-m-d\TH:i:sP") : null)}'
6257

63-
'_creationDateTime':
58+
'neos_creation_date_time':
6459
search:
6560
elasticSearchMapping:
6661
type: date
6762
format: 'date_time_no_millis'
6863
indexing: '${(node.creationDateTime ? Date.format(node.creationDateTime, "Y-m-d\TH:i:sP") : null)}'
6964

65+
# deliberately don't map or index this
66+
'_removed':
67+
search:
68+
indexing: false
69+
'_creationDateTime':
70+
search:
71+
indexing: false
72+
'_lastModificationDateTime':
73+
search:
74+
indexing: false
75+
'_lastPublicationDateTime':
76+
search:
77+
indexing: false
78+
'_hiddenBeforeDateTime':
79+
search:
80+
indexing: false
81+
'_hiddenAfterDateTime':
82+
search:
83+
indexing: false
84+
'_path':
85+
search:
86+
indexing: false
87+
'_nodeType':
88+
search:
89+
indexing: false
90+
'_name':
91+
search:
92+
indexing: false
93+
'_hidden':
94+
search:
95+
indexing: false
96+
7097
'unstructured': *node

Configuration/NodeTypes.Override.Timable.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'Neos.Neos:Timable':
22
properties:
3-
'_hiddenBeforeDateTime':
3+
'neos_hidden_before_datetime':
44
search:
55
elasticSearchMapping:
66
type: date
77
format: 'date_time_no_millis'
88
indexing: '${(node.hiddenBeforeDateTime ? Date.format(node.hiddenBeforeDateTime, "Y-m-d\TH:i:sP") : null)}'
99

10-
'_hiddenAfterDateTime':
10+
'neos_hidden_after_datetime':
1111
search:
1212
elasticSearchMapping:
1313
type: date

0 commit comments

Comments
 (0)