use of org.opensearch.indices.TypeMissingException in project OpenSearch by opensearch-project.
the class IndexShard method applyDeleteOperation.
private Engine.DeleteResult applyDeleteOperation(Engine engine, long seqNo, long opPrimaryTerm, long version, String type, String id, @Nullable VersionType versionType, long ifSeqNo, long ifPrimaryTerm, Engine.Operation.Origin origin) throws IOException {
assert opPrimaryTerm <= getOperationPrimaryTerm() : "op term [ " + opPrimaryTerm + " ] > shard term [" + getOperationPrimaryTerm() + "]";
ensureWriteAllowed(origin);
// TODO: clean this up when types are gone
try {
Mapping update = docMapper(type).getMapping();
if (update != null) {
return new Engine.DeleteResult(update);
}
} catch (MapperParsingException | IllegalArgumentException | TypeMissingException e) {
return new Engine.DeleteResult(e, version, getOperationPrimaryTerm(), seqNo, false);
}
if (mapperService.resolveDocumentType(type).equals(mapperService.documentMapper().type()) == false) {
// document in the wrong type.
throw new IllegalStateException("Deleting document from type [" + mapperService.resolveDocumentType(type) + "] while current type is [" + mapperService.documentMapper().type() + "]");
}
final Term uid = new Term(IdFieldMapper.NAME, Uid.encodeId(id));
final Engine.Delete delete = prepareDelete(type, id, uid, seqNo, opPrimaryTerm, version, versionType, origin, ifSeqNo, ifPrimaryTerm);
return delete(engine, delete);
}
use of org.opensearch.indices.TypeMissingException in project OpenSearch by opensearch-project.
the class TransportGetFieldMappingsIndexAction method shardOperation.
@Override
protected GetFieldMappingsResponse shardOperation(final GetFieldMappingsIndexRequest request, ShardId shardId) {
assert shardId != null;
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
Version indexCreatedVersion = indexService.mapperService().getIndexSettings().getIndexVersionCreated();
Predicate<String> metadataFieldPredicate = (f) -> indicesService.isMetadataField(indexCreatedVersion, f);
Predicate<String> fieldPredicate = metadataFieldPredicate.or(indicesService.getFieldFilter().apply(shardId.getIndexName()));
DocumentMapper mapper = indexService.mapperService().documentMapper();
Collection<String> typeIntersection;
if (request.types().length == 0) {
typeIntersection = mapper == null ? Collections.emptySet() : Collections.singleton(mapper.type());
} else {
typeIntersection = mapper != null && Regex.simpleMatch(request.types(), mapper.type()) ? Collections.singleton(mapper.type()) : Collections.emptySet();
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)));
}
Aggregations