Package org.elasticsearch.index.mapper

Examples of org.elasticsearch.index.mapper.FieldMapper


                    return null;
                }
                Double distance = DataTypes.DOUBLE.value(functionLiteralPair.input().value());

                String fieldName = distanceRefLiteral.reference().info().ident().columnIdent().fqn();
                FieldMapper mapper = getGeoPointFieldMapper(fieldName);
                GeoPointFieldMapper geoMapper = ((GeoPointFieldMapper) mapper);
                IndexGeoPointFieldData<?> fieldData = searchContext.fieldData().getForField(mapper);

                Input geoPointInput = distanceRefLiteral.input();
                Double[] pointValue = (Double[]) geoPointInput.value();
View Full Code Here


            }

            MultiValueMode sortMode = context.reverseFlag ? MultiValueMode.MAX : MultiValueMode.MIN;
            SearchContext searchContext = context.context.searchContext();

            FieldMapper fieldMapper = context.context.searchContext().smartNameFieldMapper(columnIdent.fqn());
            SortOrder sortOrder = new SortOrder(context.reverseFlag, context.nullFirst);
            IndexFieldData.XFieldComparatorSource fieldComparatorSource =
                    searchContext.fieldData().getForField(fieldMapper).comparatorSource(sortOrder.missing(), sortMode);

            return new SortField(
                    fieldMapper.names().indexName(),
                    fieldComparatorSource,
                    context.reverseFlag
            );
        }
View Full Code Here

        }
        return ((Number) value).floatValue();
    }

    protected Query singleQuery(MatchQuery.Type type, String fieldName, BytesRef queryString) {
        FieldMapper mapper = null;
        final String field;
        MapperService.SmartNameFieldMappers smartNameFieldMappers = searchContext.smartFieldMappers(fieldName);
        if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) {
            mapper = smartNameFieldMappers.mapper();
            field = mapper.names().indexName();
        } else {
            field = fieldName;
        }

        if (mapper != null && mapper.useTermQueryWithQueryString() && !forceAnalyzeQueryString()) {
            if (smartNameFieldMappers.explicitTypeInNameWithDocMapper()) {
                String[] previousTypes = QueryParseContext.setTypesWithPrevious(
                        new String[]{smartNameFieldMappers.docMapper().type()});
                try {
                    return wrapSmartNameQuery(
                            mapper.termQuery(queryString, null),
                            smartNameFieldMappers,
                            indexCache
                    );
                } catch (RuntimeException e) {
                    return null;
                } finally {
                    QueryParseContext.setTypes(previousTypes);
                }
            } else {
                try {
                    return wrapSmartNameQuery(
                            mapper.termQuery(queryString, null),
                            smartNameFieldMappers,
                            indexCache
                    );
                } catch (RuntimeException e) {
                    return null;
View Full Code Here

    public FieldCacheExpression(String columnName) {
        super(columnName);
    }

    public void startCollect(CollectorContext context){
        FieldMapper mapper = context.searchContext().mapperService().smartNameFieldMapper
                (columnName, DEFAULT_MAPPING_TYPES);
        indexFieldData = (IFD) context.searchContext().fieldData().getForField(mapper);
    }
View Full Code Here

        private GeoPointFieldMapper getGeoPointFieldMapper(String fieldName) {
            MapperService.SmartNameFieldMappers smartMappers = searchContext.smartFieldMappers(fieldName);
            if (smartMappers == null || !smartMappers.hasMapper()) {
                throw new IllegalArgumentException(String.format("column \"%s\" doesn't exist", fieldName));
            }
            FieldMapper mapper = smartMappers.mapper();
            if (!(mapper instanceof GeoPointFieldMapper)) {
                throw new IllegalArgumentException(String.format("column \"%s\" isn't of type geo_point", fieldName));
            }
            return (GeoPointFieldMapper) mapper;
        }
View Full Code Here

        }
        if (field == null) {
            throw new QueryParsingException(parseContext.index(), "field_masking_span must have [field] set for it");
        }

        FieldMapper mapper = parseContext.fieldMapper(field);
        if (mapper != null) {
            field = mapper.names().indexName();
        }

        FieldMaskingSpanQuery query = new FieldMaskingSpanQuery(inner, field);
        query.setBoost(boost);
        if (queryName != null) {
View Full Code Here

        Query query = null;
        MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName);
        if (smartNameFieldMappers != null) {
            if (smartNameFieldMappers.hasMapper()) {
                FieldMapper mapper = smartNameFieldMappers.mapper();
                if (mapper instanceof DateFieldMapper) {
                    if ((from instanceof Number || to instanceof Number) && timeZone != null) {
                        throw new QueryParsingException(parseContext.index(), "[range] time_zone when using ms since epoch format as it's UTC based can not be applied to [" + fieldName + "]");
                    }
                    query = ((DateFieldMapper) mapper).rangeQuery(from, to, includeLower, includeUpper, timeZone, forcedDateParser, parseContext);
                } else  {
                    if (timeZone != null) {
                        throw new QueryParsingException(parseContext.index(), "[range] time_zone can not be applied to non date field [" + fieldName + "]");
                    }
                    //LUCENE 4 UPGRADE Mapper#rangeQuery should use bytesref as well?
                    query = mapper.rangeQuery(from, to, includeLower, includeUpper, parseContext);
                }

            }
        }
        if (query == null) {
View Full Code Here

        MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName);
        if (smartNameFieldMappers == null || !smartNameFieldMappers.hasMapper()) {
            throw new QueryParsingException(parseContext.index(), "Failed to find geo_shape field [" + fieldName + "]");
        }

        FieldMapper fieldMapper = smartNameFieldMappers.mapper();
        // TODO: This isn't the nicest way to check this
        if (!(fieldMapper instanceof GeoShapeFieldMapper)) {
            throw new QueryParsingException(parseContext.index(), "Field [" + fieldName + "] is not a geo_shape");
        }
View Full Code Here

            if (smartNameFieldMappers.hasMapper()) {
                if (execution.equals("index")) {
                    if (cache == null) {
                        cache = true;
                    }
                    FieldMapper mapper = smartNameFieldMappers.mapper();
                    if (mapper instanceof DateFieldMapper) {
                        if ((from instanceof Number || to instanceof Number) && timeZone != null) {
                            throw new QueryParsingException(parseContext.index(), "[range] time_zone when using ms since epoch format as it's UTC based can not be applied to [" + fieldName + "]");
                        }
                        filter = ((DateFieldMapper) mapper).rangeFilter(from, to, includeLower, includeUpper, timeZone, forcedDateParser, parseContext, explicitlyCached);
                    } else  {
                        if (timeZone != null) {
                            throw new QueryParsingException(parseContext.index(), "[range] time_zone can not be applied to non date field [" + fieldName + "]");
                        }
                        filter = mapper.rangeFilter(from, to, includeLower, includeUpper, parseContext);
                    }
                } else if ("fielddata".equals(execution)) {
                    if (cache == null) {
                        cache = false;
                    }
                    FieldMapper mapper = smartNameFieldMappers.mapper();
                    if (!(mapper instanceof NumberFieldMapper)) {
                        throw new QueryParsingException(parseContext.index(), "[range] filter field [" + fieldName + "] is not a numeric type");
                    }
                    if (mapper instanceof DateFieldMapper) {
                        if ((from instanceof Number || to instanceof Number) && timeZone != null) {
View Full Code Here

        if (field == null) {
            throw new QueryParsingException(parseContext.index(), "[" + NAMES[0] + "] required field 'field' missing");
        }

        SearchContext searchContext = SearchContext.current();
        FieldMapper mapper = searchContext.mapperService().smartNameFieldMapper(field);
        if (mapper == null) {
            throw new ElasticsearchException("Unable to find a field mapper for field [" + field + "]");
        }
        return new FieldValueFactorFunction(field, boostFactor, modifier,
                (IndexNumericFieldData)searchContext.fieldData().getForField(mapper));
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.mapper.FieldMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.