@Override public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { throw new IllegalStateException("Field data loading is forbidden on [" + fieldType.names().fullName() + "]"); } };
public CustomNumericField(Number value, MappedFieldType fieldType) { super(fieldType.names().indexName(), fieldType); if (value != null) { this.fieldsData = value; } }
public Object getValue() { if (valueLoaded) { return value; } valueLoaded = true; value = null; List<Object> values = fields.get(fieldType.names().indexName()); return values != null ? value = values.get(0) : null; }
@Override AnalyzingSuggestHolder getAnalyzingSuggestHolder(MappedFieldType fieldType) { return lookupMap.get(fieldType.names().indexName()); }
@Override public Query termQuery(MappedFieldType fieldType, Object value) { /* * Use the string value of the term because we're reusing the * portion of the query is usually after the analyzer has run on * each term. We just skip that analyzer phase. */ return blendTerm(new Term(fieldType.names().indexName(), value.toString()), fieldType); } }
public List<Object> getValues() { if (valuesLoaded) { return values; } valuesLoaded = true; values.clear(); return values = fields().get(fieldType.names().indexName()); } }
/** * Creates a term associated with the field of this mapper for the given * value. Its important to use termQuery when building term queries because * things like ParentFieldMapper override it to make more interesting * queries. */ protected Term createTerm(Object value) { return new Term(names().indexName(), indexedValueForSearch(value)); }
/** Checks this type is the same type as other. Adds a conflict if they are different. */ private final void checkTypeName(MappedFieldType other) { if (typeName().equals(other.typeName()) == false) { throw new IllegalArgumentException("mapper [" + names().fullName() + "] cannot be changed from type [" + typeName() + "] to [" + other.typeName() + "]"); } else if (getClass() != other.getClass()) { throw new IllegalStateException("Type names equal for class " + getClass().getSimpleName() + " and " + other.getClass().getSimpleName()); } }
@Override public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { return new DoubleArrayIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, breakerService); } }
@Override public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { return new GeoPointArrayIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, breakerService); } }
@Override public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { return new FloatArrayIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, breakerService); } }
public FieldMapper smartNameFieldMapper(String name) { FieldMapper fieldMapper = getMapper(name); if (fieldMapper != null) { return fieldMapper; } for (FieldMapper otherFieldMapper : this) { if (otherFieldMapper.fieldType().names().indexName().equals(name)) { return otherFieldMapper; } } return null; }
public Collection<String> simpleMatchToFullName(String pattern) { Set<String> fields = Sets.newHashSet(); for (FieldMapper fieldMapper : this) { if (Regex.simpleMatch(pattern, fieldMapper.fieldType().names().fullName())) { fields.add(fieldMapper.fieldType().names().fullName()); } else if (Regex.simpleMatch(pattern, fieldMapper.fieldType().names().indexName())) { fields.add(fieldMapper.fieldType().names().fullName()); } } return fields; }
@Override protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException { if (!enabledState.enabled) { return; } fields.add(new Field(fieldType().names().indexName(), context.index(), fieldType())); }
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { if (this instanceof StringFieldType == false) { DEPRECATION_LOGGER.deprecated("Range query on field [{}] of type [{}] is deprecated. The next version will only support it " + "on text/keyword/numeric/date/ip fields", names().fullName(), typeName()); } return new TermRangeQuery(names().indexName(), lowerTerm == null ? null : indexedValueForSearch(lowerTerm), upperTerm == null ? null : indexedValueForSearch(upperTerm), includeLower, includeUpper); }
@Override public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore breaker return new GeoPointDVIndexFieldData(index, fieldType.names(), fieldType.fieldDataType(), Version.indexCreated(indexSettings).before(Version.V_2_2_0)); } }
@Override protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException { if (!enabledState.enabled) { return; } // reset the entries context.allEntries().reset(); Analyzer analyzer = findAnalyzer(context); fields.add(new AllField(fieldType().names().indexName(), context.allEntries(), analyzer, fieldType())); }
@Override protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException { if (context.sourceToParse().routing() != null) { String routing = context.sourceToParse().routing(); if (routing != null) { if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { fields.add(new Field(fieldType().names().indexName(), routing, fieldType())); } } } }
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { if (this instanceof StringFieldType == false) { DEPRECATION_LOGGER.deprecated("Fuzzy query on field [{}] of type [{}] is deprecated. The next version will only support it " + "on text/keyword fields", names().fullName(), typeName()); } return new FuzzyQuery(createTerm(value), fuzziness.asDistance(BytesRefs.toString(value)), prefixLength, maxExpansions, transpositions); }
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) { if (this instanceof StringFieldType == false) { DEPRECATION_LOGGER.deprecated("Prefix query on field [{}] of type [{}] is deprecated. The next version will only support it " + "on text/keyword fields", names().fullName(), typeName()); } PrefixQuery query = new PrefixQuery(createTerm(value)); if (method != null) { query.setRewriteMethod(method); } return query; }