From 976fb761b3086c011c065a52908f3bece9ea7947 Mon Sep 17 00:00:00 2001 From: Rishabh Maurya Date: Mon, 1 Apr 2024 15:31:50 -0700 Subject: [PATCH] Address PR comments and add to CHANGELOG Signed-off-by: Rishabh Maurya --- CHANGELOG.md | 1 + .../index/mapper/DerivedFieldMapper.java | 19 ------------------- .../opensearch/index/mapper/ObjectMapper.java | 6 +++--- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a43b676ce166..703da1ef1736c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Tracing for deep search path ([#12103](https://github.com/opensearch-project/OpenSearch/pull/12103)) - Add explicit dependency to validatePom and generatePom tasks ([#12807](https://github.com/opensearch-project/OpenSearch/pull/12807)) - Replace configureEach with all for publication iteration ([#12876](https://github.com/opensearch-project/OpenSearch/pull/12876)) +- Derived fields support to derive field values at query time without indexing ([#12569](https://github.com/opensearch-project/OpenSearch/pull/12569)) ### Dependencies - Bump `log4j-core` from 2.18.0 to 2.19.0 diff --git a/server/src/main/java/org/opensearch/index/mapper/DerivedFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/DerivedFieldMapper.java index 5d6d5ad2e73e8..b448487a4f810 100644 --- a/server/src/main/java/org/opensearch/index/mapper/DerivedFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/DerivedFieldMapper.java @@ -8,8 +8,6 @@ package org.opensearch.index.mapper; -import org.apache.lucene.document.FieldType; -import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexableField; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.script.Script; @@ -28,23 +26,6 @@ public class DerivedFieldMapper extends ParametrizedFieldMapper { public static final String CONTENT_TYPE = "derived"; - /** - * Default parameters for the boolean field mapper - * - * @opensearch.internal - */ - public static class Defaults { - public static final FieldType FIELD_TYPE = new FieldType(); - - static { - FIELD_TYPE.setOmitNorms(true); - FIELD_TYPE.setStored(false); - FIELD_TYPE.setTokenized(false); - FIELD_TYPE.setIndexOptions(IndexOptions.NONE); - FIELD_TYPE.freeze(); - } - } - private static DerivedFieldMapper toType(FieldMapper in) { return (DerivedFieldMapper) in; } diff --git a/server/src/main/java/org/opensearch/index/mapper/ObjectMapper.java b/server/src/main/java/org/opensearch/index/mapper/ObjectMapper.java index 2c73a53f70526..92ffdb60e6cde 100644 --- a/server/src/main/java/org/opensearch/index/mapper/ObjectMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/ObjectMapper.java @@ -294,10 +294,10 @@ protected static boolean parseObjectOrDocumentTypeProperties( } else if (fieldName.equals("derived")) { if (fieldNode instanceof Collection && ((Collection) fieldNode).isEmpty()) { // nothing to do here, empty (to support "derived: []" case) - } else if (!(fieldNode instanceof Map)) { - throw new OpenSearchParseException("derived must be a map type"); - } else { + } else if (fieldNode instanceof Map) { parseDerived(builder, (Map) fieldNode, parserContext); + } else { + throw new OpenSearchParseException("derived must be a map type"); } return true; } else if (fieldName.equals("properties")) {