nfsantos commented on code in PR #2145:
URL: https://github.com/apache/jackrabbit-oak/pull/2145#discussion_r1984624422


##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java:
##########
@@ -324,13 +325,17 @@ public String getElasticKeyword(String propertyName) {
             ElasticPropertyDefinition pd = 
getMatchingRegexPropertyDefinition(propertyName);
             if (pd != null) {
                 if (pd.isFlattened()) {
-                    return FieldNames.FLATTENED_FIELD_PREFIX + pd.nodeName + 
"." + propertyName;
+                    String fieldName = 
ElasticIndexUtils.fieldName(propertyName);
+                    String flattenedFieldName = 
FieldNames.FLATTENED_FIELD_PREFIX +
+                            ElasticIndexUtils.fieldName(pd.nodeName) + "." + 
fieldName;
+                    return flattenedFieldName;
                 }
             }
-            return propertyName + ".keyword";
+            String fieldName = ElasticIndexUtils.fieldName(propertyName);

Review Comment:
   The line `String fieldName = ElasticIndexUtils.fieldName(propertyName);` is 
executed in both cases of the conditional, so it would be more clear if it was 
moved to before the if condition. 
   
   As a personal preference, I like this style more, I find it more readable 
and clear:
   
   ```java
               String fieldName = ElasticIndexUtils.fieldName(propertyName);
               if (pd != null && pd.isFlattened()) {
                   return FieldNames.FLATTENED_FIELD_PREFIX +
                           ElasticIndexUtils.fieldName(pd.nodeName) + "." + 
fieldName;
               } else {
                 return fieldName + ".keyword";
              }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to