MultiFieldParserContext(ParserContext in) { super( in.type(), in.analysisService, in.similarityLookupService(), in.mapperService(), in.typeParsers(), in.indexVersionCreated(), in.parseFieldMatcher(), in.queryShardContext()); }
@Override public Mapper.Builder<?, ?> parse( String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException { CompletionFieldMapper.Builder builder = completionField(name); NamedAnalyzer indexAnalyzer = null; NamedAnalyzer searchAnalyzer = null; for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry<String, Object> entry = iterator.next(); String fieldName = entry.getKey(); Object fieldNode = entry.getValue(); if (fieldName.equals("type")) { continue; } if (Fields.ANALYZER.equals(fieldName) || // index_analyzer is for backcompat, remove for v3.0 fieldName.equals("index_analyzer") && parserContext.indexVersionCreated().before(Version.V_2_0_0)) { indexAnalyzer = getNamedAnalyzer(parserContext, fieldNode.toString()); iterator.remove(); } else if (parserContext.parseFieldMatcher().match(fieldName, Fields.SEARCH_ANALYZER)) { searchAnalyzer = getNamedAnalyzer(parserContext, fieldNode.toString()); iterator.remove(); } else if (fieldName.equals(Fields.PAYLOADS)) { builder.payloads(Boolean.parseBoolean(fieldNode.toString())); iterator.remove(); } else if (parserContext.parseFieldMatcher().match(fieldName, Fields.PRESERVE_SEPARATORS)) { builder.preserveSeparators(Boolean.parseBoolean(fieldNode.toString())); iterator.remove(); } else if (parserContext .parseFieldMatcher() .match(fieldName, Fields.PRESERVE_POSITION_INCREMENTS)) { builder.preservePositionIncrements(Boolean.parseBoolean(fieldNode.toString())); iterator.remove(); } else if (parserContext.parseFieldMatcher().match(fieldName, Fields.MAX_INPUT_LENGTH)) { builder.maxInputLength(Integer.parseInt(fieldNode.toString())); iterator.remove(); } else if (parseMultiField(builder, name, parserContext, fieldName, fieldNode)) { iterator.remove(); } else if (fieldName.equals(Fields.CONTEXT)) { builder.contextMapping( ContextBuilder.loadMappings(fieldNode, parserContext.indexVersionCreated())); iterator.remove(); } } if (indexAnalyzer == null) { if (searchAnalyzer != null) { throw new MapperParsingException( "analyzer on completion field [" + name + "] must be set when search_analyzer is set"); } indexAnalyzer = searchAnalyzer = parserContext.analysisService().analyzer("simple"); } else if (searchAnalyzer == null) { searchAnalyzer = indexAnalyzer; } builder.indexAnalyzer(indexAnalyzer); builder.searchAnalyzer(searchAnalyzer); return builder; }