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

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


//                boost = -1;
//            }
            for (Iterator<Object> values = representation.get(field); values.hasNext();) {
                // now we need to get the indexField for the value
                Object next = values.next();
                IndexValue value;
                try {
                    value = indexValueFactory.createIndexValue(next);
                    for (String fieldName : fieldMapper.getFieldNames(Arrays.asList(field), value)) {
                        //Set Boosts only for text data types
                        if(boost > 0){
                            inputDocument.addField(fieldName, value.getValue(), boost);
                        } else {
                            inputDocument.addField(fieldName, value.getValue());
                        }
                    }
                } catch (NoConverterException e) {
                    log.warn(
                        String.format("Unable to convert value %s (type:%s) for field %s!", next,
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

        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

        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

        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().toString().isEmpty() ? indexValue.getValue() : DEFAULT);
        constraint.addEncoded(POS, geConstraint);
    }
View Full Code Here

                boost = -1;
            }
            for (Iterator<Object> values = representation.get(field); values.hasNext();) {
                // now we need to get the indexField for the value
                Object next = values.next();
                IndexValue value;
                try {
                    value = indexValueFactory.createIndexValue(next);
                    for (String fieldName : fieldMapper.getFieldNames(Arrays.asList(field), value)) {
                        if(boost > 0){
                            inputDocument.addField(fieldName, value.getValue(), boost);
                        } else {
                            inputDocument.addField(fieldName, value.getValue());
                        }
                    }
                } catch (Exception e) {
                    log.warn(
                        String.format("Unable to process value %s (type:%s) for field %s!", next,
View Full Code Here

                // constraint per query

                List<String> fields = new ArrayList<String>();
                fields.add(fieldConstraint.getKey());
                SimilarityConstraint simConstraint = (SimilarityConstraint) fieldConstraint.getValue();
                IndexValue indexValue = indexValueFactory.createIndexValue(simConstraint.getContext());
                fields.addAll(simConstraint.getAdditionalFields());
                if(!similarityConstraintPresent){
                    similarityConstraintPresent = true; //similarity constraint present
                    //add the constraint to the query
                    query.setQueryType(MLT_QUERY_TYPE);
                    query.set(MATCH_INCLUDE, false);
                    query.set(MIN_DOC_FREQ, 1);
                    query.set(MIN_TERM_FREQ, 1);
                    query.set(INTERESTING_TERMS, "details");
                    List<String> indexFields = new ArrayList<String>();
                    for(String field : fields){
                        IndexField indexField = new IndexField(Collections.singletonList(field),
                            IndexDataTypeEnum.TXT.getIndexType());
                        indexFields.addAll(fieldMapper.getFieldNames(indexField));
                    }
                    query.set(SIMILARITY_FIELDS, indexFields.toArray(new String[fields.size()]));
                    query.set(STREAM_BODY, indexValue.getValue());
                    processedFieldConstraints.put(fieldConstraint.getKey(), fieldConstraint.getValue());
                } else { //similarity constraint already present -> ignore further
                    //NOTE: users are informed about that by NOT including further
                    //      similarity constraints in the query included in the
                    //      response
View Full Code Here

                    }
                }
            } //else empty we will initialise based on the first parsed value!
            ConstraintValue constraintValue = new ConstraintValue(valueConstraint.getMode());
            for(Object value : valueConstraint.getValues()){
                IndexValue indexValue;
                if(indexDataType == null){ // if no supported types are present
                    // get the dataType based on the type of the value
                    try {
                        indexValue = indexValueFactory.createIndexValue(value);
                    } 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[]{
                                        value, value.getClass(),
                                        IndexDataTypeEnum.STR.getIndexType()
                                    });
                        indexValue = new IndexValue(value.toString(),
                            IndexDataTypeEnum.STR.getIndexType());
                    }
                    //initialise the IndexDataType for this query based on the first parsed value
                    indexDataType = indexValue.getType();
                } else {
                    indexValue = new IndexValue(value.toString(), indexDataType);
                }
                constraintValue.getValues().add(indexValue); //add the constraint
            }
            //indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.DATATYPE, indexDataType);
            IndexField indexField;
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("{%s ",
            indexValue != null && indexValue.getValue() != null
                    && !indexValue.getValue().toString().isEmpty() ? indexValue.getValue() : DEFAULT);
        constraint.addEncoded(POS, geConstraint);
    }
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.