Java Code Examples for org.elasticsearch.common.xcontent.ToXContent#EMPTY_PARAMS
The following examples show how to use
org.elasticsearch.common.xcontent.ToXContent#EMPTY_PARAMS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MappingMetaData.java From crate with Apache License 2.0 | 5 votes |
public MappingMetaData(String type, Map<String, Object> mapping) throws IOException { this.type = type; this.source = new CompressedXContent( (builder, params) -> builder.mapContents(mapping), XContentType.JSON, ToXContent.EMPTY_PARAMS); Map<String, Object> withoutType = mapping; if (mapping.size() == 1 && mapping.containsKey(type)) { withoutType = (Map<String, Object>) mapping.get(type); } initMappers(withoutType); }
Example 2
Source File: DocumentMapper.java From crate with Apache License 2.0 | 4 votes |
public DocumentMapper(MapperService mapperService, Mapping mapping) { this.mapperService = mapperService; this.type = mapping.root().name(); final IndexSettings indexSettings = mapperService.getIndexSettings(); this.mapping = mapping; this.documentParser = new DocumentParser(indexSettings, mapperService.documentMapperParser(), this); // collect all the mappers for this type List<ObjectMapper> newObjectMappers = new ArrayList<>(); List<FieldMapper> newFieldMappers = new ArrayList<>(); List<FieldAliasMapper> newFieldAliasMappers = new ArrayList<>(); for (MetadataFieldMapper metadataMapper : this.mapping.metadataMappers) { if (metadataMapper != null) { newFieldMappers.add(metadataMapper); } } MapperUtils.collect(this.mapping.root, newObjectMappers, newFieldMappers, newFieldAliasMappers); final IndexAnalyzers indexAnalyzers = mapperService.getIndexAnalyzers(); this.fieldMappers = new DocumentFieldMappers(newFieldMappers, newFieldAliasMappers, indexAnalyzers.getDefaultIndexAnalyzer(), indexAnalyzers.getDefaultSearchAnalyzer(), indexAnalyzers.getDefaultSearchQuoteAnalyzer()); Map<String, ObjectMapper> builder = new HashMap<>(); for (ObjectMapper objectMapper : newObjectMappers) { ObjectMapper previous = builder.put(objectMapper.fullPath(), objectMapper); if (previous != null) { throw new IllegalStateException("duplicate key " + objectMapper.fullPath() + " encountered"); } } this.objectMappers = Collections.unmodifiableMap(builder); try { mappingSource = new CompressedXContent(this, XContentType.JSON, ToXContent.EMPTY_PARAMS); } catch (Exception e) { throw new ElasticsearchGenerationException("failed to serialize source for type [" + type + "]", e); } final Collection<String> deleteTombstoneMetadataFields = Arrays.asList(VersionFieldMapper.NAME, IdFieldMapper.NAME, SeqNoFieldMapper.NAME, SeqNoFieldMapper.PRIMARY_TERM_NAME, SeqNoFieldMapper.TOMBSTONE_NAME); this.deleteTombstoneMetadataFieldMappers = Stream.of(mapping.metadataMappers) .filter(field -> deleteTombstoneMetadataFields.contains(field.name())).toArray(MetadataFieldMapper[]::new); final Collection<String> noopTombstoneMetadataFields = Arrays.asList( VersionFieldMapper.NAME, SeqNoFieldMapper.NAME, SeqNoFieldMapper.PRIMARY_TERM_NAME, SeqNoFieldMapper.TOMBSTONE_NAME); this.noopTombstoneMetadataFieldMappers = Stream.of(mapping.metadataMappers) .filter(field -> noopTombstoneMetadataFields.contains(field.name())).toArray(MetadataFieldMapper[]::new); }
Example 3
Source File: AbstractSerializingTestCase.java From crate with Apache License 2.0 | 4 votes |
/** * Params that have to be provided when calling calling {@link ToXContent#toXContent(XContentBuilder, ToXContent.Params)} */ protected ToXContent.Params getToXContentParams() { return ToXContent.EMPTY_PARAMS; }
Example 4
Source File: AbstractXContentTestCase.java From crate with Apache License 2.0 | 4 votes |
/** * Params that have to be provided when calling {@link ToXContent#toXContent(XContentBuilder, ToXContent.Params)} */ protected ToXContent.Params getToXContentParams() { return ToXContent.EMPTY_PARAMS; }