
org.elasticsearch.index.mapper.NestedValueFetcher Maven / Gradle / Ivy
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.index.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.document.DocumentField;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.search.fetch.StoredFieldsSpec;
import org.elasticsearch.search.fetch.subphase.FieldFetcher;
import org.elasticsearch.search.lookup.Source;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NestedValueFetcher implements ValueFetcher {
private final String nestedFieldPath;
private final FieldFetcher nestedFieldFetcher;
// the name of the nested field without the full path, i.e. in foo.bar.baz it would be baz
private final String nestedFieldName;
private final String[] nestedPathParts;
public NestedValueFetcher(String nestedField, FieldFetcher nestedFieldFetcher) {
assert nestedField != null && nestedField.isEmpty() == false;
this.nestedFieldPath = nestedField;
this.nestedFieldFetcher = nestedFieldFetcher;
this.nestedPathParts = nestedFieldPath.split("\\.");
this.nestedFieldName = nestedPathParts[nestedPathParts.length - 1];
}
@Override
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy