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


##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java:
##########
@@ -207,21 +222,57 @@ private static void mapIndexRules(ElasticIndexDefinition 
indexDefinition, XConte
                     useInSuggest = true;
                 }
             }
-
+            /* TODO: (Add JIRA issue # once available) Potential future 
optimization:
+             *  If a property has propertyIndex=false, we could in principle 
create an ES mapping with index=false to
+             *  avoid creating an index for this property, thus saving time 
and space. However, there is an issue
+             *  with function indexes, which incorrectly rely on the index 
being created even in the case where
+             *  propertyIndex=false. Once this issue is solved, revise the 
logic below to set index=false in the ES
+             *  field if propertyIndex=false.
+             */
             mappingBuilder.startObject(name);
             {
                 // 
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html
                 if (Type.BINARY.equals(type)) {
                     mappingBuilder.field("type", "binary");
+                    // ignore_malformed not allowed for binary fields but also 
not needed as there is no type conversion
+                    if (indexDefinition.isAnalyzed(propertyDefinitions)) {
+                        createNestedAnalyzed(mappingBuilder);
+                    }
                 } else if (Type.LONG.equals(type)) {
                     mappingBuilder.field("type", "long");
+                    mappingBuilder.field("ignore_malformed", true);
+                    if (indexDefinition.isAnalyzed(propertyDefinitions)) {
+                        createNestedAnalyzed(mappingBuilder);
+                    }
                 } else if (Type.DOUBLE.equals(type) || 
Type.DECIMAL.equals(type)) {
                     mappingBuilder.field("type", "double");
+                    mappingBuilder.field("ignore_malformed", true);
+                    if (indexDefinition.isAnalyzed(propertyDefinitions)) {
+                        createNestedAnalyzed(mappingBuilder);
+                    }
                 } else if (Type.DATE.equals(type)) {
                     mappingBuilder.field("type", "date");
+                    mappingBuilder.field("ignore_malformed", true);
+                    if (indexDefinition.isAnalyzed(propertyDefinitions)) {
+                        createNestedAnalyzed(mappingBuilder);
+                    }
                 } else if (Type.BOOLEAN.equals(type)) {
                     mappingBuilder.field("type", "boolean");
+                    // ES does not support "ignore_malformed" on boolean 
properties, so all values added to the index
+                    // must parse as valid booleans or else the document is 
rejected. We therefore also do not support
+                    // the nested full text field, because to do so we would 
need to provide a value for the top level
+                    // field, which must be a valid value. As in this case we 
cannot set ignore_malformed=true to still
+                    // index as full-text the invalid values, we cannot have a 
full-text index. This breaks compatibility
+                    // with Lucene, which accepts any value, even if it is not 
a valid boolean, but this is unlikely to
+                    // have much impact because setting analyzed=true in a 
boolean property should have no real world

Review Comment:
   I added this comment to the Elastic documentation:
   
   ```
   * Properties of type Boolean do not support `analyzed=true`.
   ```



-- 
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: dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to