Package org.apache.stanbol.entityhub.yard.solr.model

Examples of org.apache.stanbol.entityhub.yard.solr.model.IndexValue


        this.indexValueFactory = indexValueFactory;
    }

    @Override
    public void encode(EncodedConstraintParts constraint, Object value) {
        IndexValue indexValue;
        if (value == null) {
            indexValue = null; // default value
        } else if (value instanceof IndexValue) {
            indexValue = (IndexValue) value;
        } else {
            indexValue = indexValueFactory.createIndexValue(value);
        }
        String geConstraint = String
                .format("[%s ", indexValue != null && indexValue.getValue() != null
                                && !indexValue.getValue().isEmpty() ? indexValue.getValue() : DEFAULT);
        constraint.addEncoded(POS, geConstraint);
    }
View Full Code Here


            if (fieldConstraint.getValue().getType() == ConstraintType.similarity) {
                // TODO: log make the FieldQuery ensure that there is no more than one instead of similarity
                // constraint per query
                List<String> fields = Arrays.asList(fieldConstraint.getKey());
                SimilarityConstraint simConstraint = (SimilarityConstraint) fieldConstraint.getValue();
                IndexValue indexValue = indexValueFactory.createIndexValue(simConstraint.getContext());
                fields.addAll(simConstraint.getAdditionalFields());
                query.setQueryType(MLT_QUERY_TYPE);
                query.set(MoreLikeThisParams.MATCH_INCLUDE, false);
                query.set(MoreLikeThisParams.MIN_DOC_FREQ, 1);
                query.set(MoreLikeThisParams.MIN_TERM_FREQ, 1);
                query.set(MoreLikeThisParams.INTERESTING_TERMS, "details");

                // TODO: right now we ignore the fields and fallback to the hardcoded "_text" field
                //Collection<String> mappedFields = fieldMapper.getFieldNames(fields, indexValue);
                //query.set(MoreLikeThisParams.SIMILARITY_FIELDS, StringUtils.join(mappedFields, ","));
                query.set(MoreLikeThisParams.SIMILARITY_FIELDS, "_text");
                query.set(CommonParams.STREAM_BODY, indexValue.getValue());
            } else {
                IndexConstraint indexConstraint = createIndexConstraint(fieldConstraint);
                if (indexConstraint.isInvalid()) {
                    log.warn("Unable to create IndexConstraint for Constraint {} (type: {}) and Field {} (Reosens: {})",
                        new Object[]{
View Full Code Here

                            "supported and will be ignored (dataTypeUri={})",
                                dataType);
                    }
                }
            }
            IndexValue constraintValue;
            if(indexDataTypes.isEmpty()){ // if no supported types are present
                // get the dataType based on the type of the value
                try {
                    constraintValue = indexValueFactory.createIndexValue(valueConstraint.getValue());
                } catch (NoConverterException e) {
                    // if not found use the toString() and string as type
                    log.warn("Unable to create IndexValue for value {} (type: {}). Create IndexValue manually by using the first parsed IndexDataType {}",
                                new Object[]{
                                    valueConstraint.getValue(), valueConstraint.getValue().getClass(),
                                    IndexDataTypeEnum.STR.getIndexType()
                                });
                    constraintValue = new IndexValue(valueConstraint.getValue().toString(),
                        IndexDataTypeEnum.STR.getIndexType());
                }
                acceptedDataTypes.add(constraintValue.getType().getId());
            } else {
                constraintValue = new IndexValue(valueConstraint.getValue().toString(), indexDataTypes.get(0));
                //we support only a single dataType ...
                //  ... therefore remove additional data types from the ValueConstraint
                if(indexDataTypes.size() > 1){
                    log.warn("Only a single DataType is supported for ValueConstraints!");
                    while(acceptedDataTypes.size()>1){
                        String ignored = acceptedDataTypes.remove(acceptedDataTypes.size()-1);
                        log.warn("  > ignore parsed dataType {}",ignored);
                    }
                }
            }
            indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.DATATYPE, constraintValue);
            if(IndexDataTypeEnum.TXT.getIndexType().equals(constraintValue.getType())){
                //NOTE: in case of TEXT we need also to add the language to create a valid
                //query!
                indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.LANG,
                    Collections.singleton(constraintValue.getLanguage()));
            }
            indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue);
            //update this constraint!
            if(valueConstraint instanceof ReferenceConstraint){
                indexConstraint.setFieldQueryConstraint(valueConstraint);
View Full Code Here

        this.indexValueFactory = indexValueFactory;
    }

    @Override
    public void encode(EncodedConstraintParts constraint, Object value) {
        IndexValue indexValue;
        if (value == null) {
            indexValue = null; // default value
        } else if (value instanceof IndexValue) {
            indexValue = (IndexValue) value;
        } else {
            indexValue = indexValueFactory.createIndexValue(value);
        }
        String geConstraint = String
                .format("TO %s]", indexValue != null && indexValue.getValue() != null
                                  && !indexValue.getValue().isEmpty() ? indexValue.getValue() : DEFAULT);
        constraint.addEncoded(POS, geConstraint);
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.yard.solr.model.IndexValue

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.