/** * Returns the narrowed down explicit types, or, if not set, all types. */ public Collection<String> queryTypes() { String[] types = getTypes(); if (types == null || types.length == 0) { return getMapperService().types(); } if (types.length == 1 && types[0].equals("_all")) { return getMapperService().types(); } return Arrays.asList(types); }
public void postProcess(MapperService mapperService) { if (mapperService.getIndexSettings().isSingleType()) { final Collection<String> types = mapperService.types(); assert types.size() <= 1 : types; if (types.isEmpty() == false) { type = types.iterator().next(); } } for (Map.Entry<String, List<Object>> entry : fields().entrySet()) { MappedFieldType fieldType = mapperService.fullName(entry.getKey()); if (fieldType == null) { throw new IllegalStateException("Field [" + entry.getKey() + "] exists in the index but not in mappings"); } List<Object> fieldValues = entry.getValue(); for (int i = 0; i < fieldValues.size(); i++) { fieldValues.set(i, fieldType.valueForDisplay(fieldValues.get(i))); } } }
@Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { if (hasDocValues()) { return new DocValuesIndexFieldData.Builder(); } else { // means the index has a single type and the type field is implicit Function<MapperService, String> typeFunction = mapperService -> { Collection<String> types = mapperService.types(); if (types.size() > 1) { throw new AssertionError(); } // If we reach here, there is necessarily one type since we were able to find a `_type` field String type = types.iterator().next(); return type; }; return new ConstantIndexFieldData.Builder(typeFunction); } }
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { DEPRECATION_LOGGER.deprecated("Fielddata access on the _uid field is deprecated, use _id instead"); MappedFieldType idFieldType = mapperService.fullName(IdFieldMapper.NAME); IndexFieldData<?> idFieldData = idFieldType.fielddataBuilder(fullyQualifiedIndexName) .build(indexSettings, idFieldType, cache, breakerService, mapperService); final String type = mapperService.types().iterator().next(); return new UidIndexFieldData(indexSettings.getIndex(), type, idFieldData); } };
return super.termsQuery(values, context); Collection<String> indexTypes = context.getMapperService().types(); if (indexTypes.isEmpty()) { return new MatchNoDocsQuery("No types");
@Override protected Query doToQuery(QueryShardContext context) throws IOException { Query query; MappedFieldType uidField = context.fieldMapper(UidFieldMapper.NAME); if (uidField == null) { return new MatchNoDocsQuery("No mappings"); } if (this.ids.isEmpty()) { query = Queries.newMatchNoDocsQuery("Missing ids in \"" + this.getName() + "\" query."); } else { Collection<String> typesForQuery; if (types.length == 0) { typesForQuery = context.queryTypes(); } else if (types.length == 1 && MetaData.ALL.equals(types[0])) { typesForQuery = context.getMapperService().types(); } else { typesForQuery = new HashSet<>(); Collections.addAll(typesForQuery, types); } query = uidField.termsQuery(Arrays.asList(Uid.createUidsForTypesAndIds(typesForQuery, ids)), context); } return query; }
@Override public Query termsQuery(List<?> values, QueryShardContext context) { if (context.getIndexSettings().isSingleType()) { Collection<String> indexTypes = context.getMapperService().types(); if (indexTypes.isEmpty()) { return new MatchNoDocsQuery("No types");
@Override protected GetFieldMappingsResponse shardOperation(final GetFieldMappingsIndexRequest request, ShardId shardId) { assert shardId != null; IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex()); Predicate<String> metadataFieldPredicate = indicesService::isMetaDataField; Predicate<String> fieldPredicate = metadataFieldPredicate.or(indicesService.getFieldFilter().apply(shardId.getIndexName())); Collection<String> typeIntersection; if (request.types().length == 0) { typeIntersection = indexService.mapperService().types(); } else { typeIntersection = indexService.mapperService().types() .stream() .filter(type -> Regex.simpleMatch(request.types(), type)) .collect(Collectors.toCollection(ArrayList::new)); if (typeIntersection.isEmpty()) { throw new TypeMissingException(shardId.getIndex(), request.types()); } } Map<String, Map<String, FieldMappingMetaData>> typeMappings = new HashMap<>(); for (String type : typeIntersection) { DocumentMapper documentMapper = indexService.mapperService().documentMapper(type); Map<String, FieldMappingMetaData> fieldMapping = findFieldMappingsByType(fieldPredicate, documentMapper, request); if (!fieldMapping.isEmpty()) { typeMappings.put(type, fieldMapping); } } return new GetFieldMappingsResponse(singletonMap(shardId.getIndexName(), Collections.unmodifiableMap(typeMappings))); }
"Running [range] query on [_type] field for an index with a single type. As types are deprecated," + " this functionality will be removed in future releases."); Collection<String> types = context.getMapperService().types(); String type = types.iterator().hasNext() ? types.iterator().next() : null; if (type != null) {
final Collection<String> types; if (type == null || type.equals("_all")) { types = mapperService.types(); } else { types = Collections.singleton(type);
innerHitBuilder.getStoredFieldsContext() != null && innerHitBuilder.getStoredFieldsContext().fetchFields() == false && context.getMapperService().types().size() > 1) {
if (context.getMapperService().types().isEmpty()) {
/** * Returns the narrowed down explicit types, or, if not set, all types. */ public Collection<String> queryTypes() { String[] types = getTypes(); if (types == null || types.length == 0) { return getMapperService().types(); } if (types.length == 1 && types[0].equals("_all")) { return getMapperService().types(); } return Arrays.asList(types); }
/** * Returns the narrowed down explicit types, or, if not set, all types. */ public Collection<String> queryTypes() { String[] types = getTypes(); if (types == null || types.length == 0) { return getMapperService().types(); } if (types.length == 1 && types[0].equals("_all")) { return getMapperService().types(); } return Arrays.asList(types); }
/** * Returns the narrowed down explicit types, or, if not set, all types. */ public Collection<String> queryTypes() { String[] types = getTypes(); if (types == null || types.length == 0) { return getMapperService().types(); } if (types.length == 1 && types[0].equals("_all")) { return getMapperService().types(); } return Arrays.asList(types); }
/** * Returns the narrowed down explicit types, or, if not set, all types. */ public Collection<String> queryTypes() { String[] types = getTypes(); if (types == null || types.length == 0) { return mapperService().types(); } if (types.length == 1 && types[0].equals("_all")) { return mapperService().types(); } return Arrays.asList(types); }
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { MappedFieldType idFieldType = mapperService.fullName(IdFieldMapper.NAME); IndexOrdinalsFieldData idFieldData = (IndexOrdinalsFieldData) idFieldType.fielddataBuilder() .build(indexSettings, idFieldType, cache, breakerService, mapperService); final String type = mapperService.types().iterator().next(); return new UidIndexFieldData(indexSettings.getIndex(), type, idFieldData); } };
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { DEPRECATION_LOGGER.deprecated("Fielddata access on the _uid field is deprecated, use _id instead"); MappedFieldType idFieldType = mapperService.fullName(IdFieldMapper.NAME); IndexFieldData<?> idFieldData = idFieldType.fielddataBuilder(fullyQualifiedIndexName) .build(indexSettings, idFieldType, cache, breakerService, mapperService); final String type = mapperService.types().iterator().next(); return new UidIndexFieldData(indexSettings.getIndex(), type, idFieldData); } };
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { DEPRECATION_LOGGER.deprecated("Fielddata access on the _uid field is deprecated, use _id instead"); MappedFieldType idFieldType = mapperService.fullName(IdFieldMapper.NAME); IndexFieldData<?> idFieldData = idFieldType.fielddataBuilder(fullyQualifiedIndexName) .build(indexSettings, idFieldType, cache, breakerService, mapperService); final String type = mapperService.types().iterator().next(); return new UidIndexFieldData(indexSettings.getIndex(), type, idFieldData); } };