Package org.elasticsearch.index.search
Class QueryParserHelper
- java.lang.Object
-
- org.elasticsearch.index.search.QueryParserHelper
-
public final class QueryParserHelper extends java.lang.ObjectHelpers to extract and expand field names and boosts
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MappergetFieldMapper(MapperService mapperService, java.lang.String field)Get aFieldMapperassociated with a field name or null.static java.util.Map<java.lang.String,java.lang.Float>parseFieldsAndWeights(java.util.List<java.lang.String> fields)Convert a list of field names encoded with optional boosts to a map that associates the field name and its boost.static java.util.Map<java.lang.String,java.lang.Float>resolveMappingField(QueryShardContext context, java.lang.String fieldOrPattern, float weight, boolean acceptAllTypes, boolean acceptMetadataField)Resolves the provided pattern or field name from theQueryShardContextand return a map of the expanded fields with their original boost.static java.util.Map<java.lang.String,java.lang.Float>resolveMappingField(QueryShardContext context, java.lang.String fieldOrPattern, float weight, boolean acceptAllTypes, boolean acceptMetadataField, java.lang.String fieldSuffix)Resolves the provided pattern or field name from theQueryShardContextand return a map of the expanded fields with their original boost.static java.util.Map<java.lang.String,java.lang.Float>resolveMappingFields(QueryShardContext context, java.util.Map<java.lang.String,java.lang.Float> fieldsAndWeights)static java.util.Map<java.lang.String,java.lang.Float>resolveMappingFields(QueryShardContext context, java.util.Map<java.lang.String,java.lang.Float> fieldsAndWeights, java.lang.String fieldSuffix)Resolve all the field names and patterns present in the provided map with theQueryShardContextand returns a new map containing all the expanded fields with their original boost.
-
-
-
Method Detail
-
parseFieldsAndWeights
public static java.util.Map<java.lang.String,java.lang.Float> parseFieldsAndWeights(java.util.List<java.lang.String> fields)
Convert a list of field names encoded with optional boosts to a map that associates the field name and its boost.- Parameters:
fields- The list of fields encoded with optional boosts (e.g. ^0.35).- Returns:
- The converted map with field names and associated boosts.
-
getFieldMapper
public static Mapper getFieldMapper(MapperService mapperService, java.lang.String field)
Get aFieldMapperassociated with a field name or null.- Parameters:
mapperService- The mapper service where to find the mapping.field- The field name to search.
-
resolveMappingFields
public static java.util.Map<java.lang.String,java.lang.Float> resolveMappingFields(QueryShardContext context, java.util.Map<java.lang.String,java.lang.Float> fieldsAndWeights)
-
resolveMappingFields
public static java.util.Map<java.lang.String,java.lang.Float> resolveMappingFields(QueryShardContext context, java.util.Map<java.lang.String,java.lang.Float> fieldsAndWeights, java.lang.String fieldSuffix)
Resolve all the field names and patterns present in the provided map with theQueryShardContextand returns a new map containing all the expanded fields with their original boost.- Parameters:
context- The context of the query.fieldsAndWeights- The map of fields and weights to expand.fieldSuffix- The suffix name to add to the expanded field names if a mapping exists for that name. The original name of the field is kept if adding the suffix to the field name does not point to a valid field in the mapping.
-
resolveMappingField
public static java.util.Map<java.lang.String,java.lang.Float> resolveMappingField(QueryShardContext context, java.lang.String fieldOrPattern, float weight, boolean acceptAllTypes, boolean acceptMetadataField)
Resolves the provided pattern or field name from theQueryShardContextand return a map of the expanded fields with their original boost.- Parameters:
context- The context of the queryfieldOrPattern- The field name or the pattern to resolveweight- The weight for the fieldacceptAllTypes- Whether all field type should be added when a pattern is expanded. If false, onlyALLOWED_QUERY_MAPPER_TYPESare accepted and other field types are discarded from the query.acceptMetadataField- Whether metadata fields should be added when a pattern is expanded.
-
resolveMappingField
public static java.util.Map<java.lang.String,java.lang.Float> resolveMappingField(QueryShardContext context, java.lang.String fieldOrPattern, float weight, boolean acceptAllTypes, boolean acceptMetadataField, java.lang.String fieldSuffix)
Resolves the provided pattern or field name from theQueryShardContextand return a map of the expanded fields with their original boost.- Parameters:
context- The context of the queryfieldOrPattern- The field name or the pattern to resolveweight- The weight for the fieldacceptAllTypes- Whether all field type should be added when a pattern is expanded. If false, onlyALLOWED_QUERY_MAPPER_TYPESare accepted and other field types are discarded from the query.acceptMetadataField- Whether metadata fields should be added when a pattern is expanded.fieldSuffix- The suffix name to add to the expanded field names if a mapping exists for that name. The original name of the field is kept if adding the suffix to the field name does not point to a valid field in the mapping.
-
-