Search in sources :

Example 51 with SourceToParse

use of org.opensearch.index.mapper.SourceToParse in project OpenSearch by opensearch-project.

the class TermVectorsService method parseDocument.

private static ParsedDocument parseDocument(IndexShard indexShard, String index, BytesReference doc, XContentType xContentType, String routing) {
    MapperService mapperService = indexShard.mapperService();
    DocumentMapperForType docMapper = mapperService.documentMapperWithAutoCreate();
    ParsedDocument parsedDocument = docMapper.getDocumentMapper().parse(new SourceToParse(index, "_id_for_tv_api", doc, xContentType, routing));
    if (docMapper.getMapping() != null) {
        parsedDocument.addDynamicMappingsUpdate(docMapper.getMapping());
    }
    return parsedDocument;
}
Also used : ParsedDocument(org.opensearch.index.mapper.ParsedDocument) DocumentMapperForType(org.opensearch.index.mapper.DocumentMapperForType) SourceToParse(org.opensearch.index.mapper.SourceToParse) MapperService(org.opensearch.index.mapper.MapperService)

Aggregations

SourceToParse (org.opensearch.index.mapper.SourceToParse)51 ParsedDocument (org.opensearch.index.mapper.ParsedDocument)30 DocumentMapper (org.opensearch.index.mapper.DocumentMapper)20 Matchers.containsString (org.hamcrest.Matchers.containsString)19 CompressedXContent (org.opensearch.common.compress.CompressedXContent)18 BytesArray (org.opensearch.common.bytes.BytesArray)17 IndexableField (org.apache.lucene.index.IndexableField)15 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)13 BytesRef (org.apache.lucene.util.BytesRef)9 IndexService (org.opensearch.index.IndexService)9 MapperService (org.opensearch.index.mapper.MapperService)9 BytesReference (org.opensearch.common.bytes.BytesReference)7 Engine (org.opensearch.index.engine.Engine)7 BoolQueryBuilder (org.opensearch.index.query.BoolQueryBuilder)7 BoostingQueryBuilder (org.opensearch.index.query.BoostingQueryBuilder)7 ConstantScoreQueryBuilder (org.opensearch.index.query.ConstantScoreQueryBuilder)7 DisMaxQueryBuilder (org.opensearch.index.query.DisMaxQueryBuilder)7 MatchAllQueryBuilder (org.opensearch.index.query.MatchAllQueryBuilder)7 QueryBuilder (org.opensearch.index.query.QueryBuilder)7 RangeQueryBuilder (org.opensearch.index.query.RangeQueryBuilder)7