Skip to content

Commit

Permalink
Fix the breaking change check due to Derived fields changes in 2.15 (o…
Browse files Browse the repository at this point in the history
…pensearch-project#14143)

Signed-off-by: Rishabh Maurya <[email protected]>
  • Loading branch information
rishabhmaurya authored Jun 10, 2024
1 parent 214ba42 commit 4fd5f19
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LeafReaderContext;
import org.opensearch.common.annotation.DeprecatedApi;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.script.DerivedFieldScript;
import org.opensearch.search.lookup.SourceLookup;
Expand All @@ -28,14 +29,23 @@
public class DerivedFieldValueFetcher implements ValueFetcher {
private DerivedFieldScript derivedFieldScript;
private final DerivedFieldScript.LeafFactory derivedFieldScriptFactory;

private final Function<Object, Object> valueForDisplay;

public DerivedFieldValueFetcher(DerivedFieldScript.LeafFactory derivedFieldScriptFactory, Function<Object, Object> valueForDisplay) {
this.derivedFieldScriptFactory = derivedFieldScriptFactory;
this.valueForDisplay = valueForDisplay;
}

@DeprecatedApi(since = "2.15.0")
public DerivedFieldValueFetcher(
DerivedFieldScript.LeafFactory derivedFieldScriptFactory,
Function<Object, Object> valueForDisplay,
Function<Object, IndexableField> indexableFieldFunction
) {
this.derivedFieldScriptFactory = derivedFieldScriptFactory;
this.valueForDisplay = valueForDisplay;
}

@Override
public List<Object> fetchValues(SourceLookup lookup) {
List<Object> values = fetchValuesInternal(lookup);
Expand Down Expand Up @@ -66,6 +76,14 @@ public List<IndexableField> getIndexableField(SourceLookup lookup, Function<Obje
return indexableFields;
}

/**
* Use {@link #getIndexableField(SourceLookup, Function)} instead
*/
@DeprecatedApi(since = "2.15.0")
public List<IndexableField> getIndexableField(SourceLookup sourceLookup) {
throw new UnsupportedOperationException("Use getIndexableField(SourceLookup, Function) instead.");
}

@Override
public void setNextReader(LeafReaderContext context) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opensearch.common.CheckedFunction;
import org.opensearch.common.SetOnce;
import org.opensearch.common.TriFunction;
import org.opensearch.common.annotation.DeprecatedApi;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lucene.search.Queries;
import org.opensearch.common.util.BigArrays;
Expand Down Expand Up @@ -414,6 +415,16 @@ public void setDerivedFieldResolver(DerivedFieldResolver derivedFieldResolver) {
this.derivedFieldResolver = derivedFieldResolver;
}

@DeprecatedApi(since = "2.15.0")
public void setDerivedFieldTypes(Map<String, MappedFieldType> derivedFieldTypeMap) {
throw new UnsupportedOperationException("Use setDerivedFieldResolver() instead.");
}

@DeprecatedApi(since = "2.15.0")
public MappedFieldType getDerivedFieldType(String fieldName) {
throw new UnsupportedOperationException("Use resolveDerivedFieldType() instead.");
}

public void setAllowUnmappedFields(boolean allowUnmappedFields) {
this.allowUnmappedFields = allowUnmappedFields;
}
Expand Down

0 comments on commit 4fd5f19

Please sign in to comment.