Package org.apache.stanbol.entityhub.servicesapi.query

Examples of org.apache.stanbol.entityhub.servicesapi.query.TextConstraint


        // TODO: make case sensitivity configurable
        boolean casesensitive = false;
        String namedEntityLabel = casesensitive ? namedEntity.getName() : namedEntity.getName().toLowerCase();
        if (language != null) {
            // search labels in the language and without language
            labelConstraint = new TextConstraint(namedEntityLabel, casesensitive, language, null);
        } else {
            labelConstraint = new TextConstraint(namedEntityLabel, casesensitive);
        }
        query.setConstraint(nameField, labelConstraint);
        if (OntologicalClasses.DBPEDIA_PERSON.equals(namedEntity.getType())) {
            if (personState) {
                if (personType != null) {
View Full Code Here


            InMemoryValueFactory.getInstance(),
            IndexValueFactory.getInstance(),
            new SolrFieldMapper(null));
        FieldQuery query = DefaultQueryFactory.getInstance().createFieldQuery();
//        query.setConstraint("urn:field2", new TextConstraint("test","en","de"));
        query.setConstraint("urn:field3", new TextConstraint(Arrays.asList(
            "text value","anothertest","some more values"),"en","de",null));
        query.addSelectedField("urn:field2a");
        query.addSelectedField("urn:field3");
        query.setLimit(5);
        query.setOffset(5);
View Full Code Here

                    entityhub.getQueryFactory().createFieldQuery();
        query.addSelectedField(nameField);
        query.addSelectedField(NamespaceEnum.rdfs+"comment");
        query.addSelectedField(NamespaceEnum.rdf+"type");
        query.addSelectedField(NamespaceEnum.rdfs+"seeAlso");
        query.setConstraint(nameField, new TextConstraint(searchString));//,language));
        //select 5 times the number of suggestion to allow some post
        //filtering
        //TODO: convert this to additional queries with offset
        query.setLimit(Integer.valueOf(maxSuggestions*5));
        QueryResultList<Representation> result;
View Full Code Here

        FieldQueryFactory qf = DefaultQueryFactory.getInstance();
        FieldQuery fieldQuery = qf.createFieldQuery();
        Collection<String> selectedFields = new ArrayList<String>();
        selectedFields.add(RDFS.label.getUnicodeString());
        fieldQuery.addSelectedFields(selectedFields);
        fieldQuery.setConstraint(RDFS.label.getUnicodeString(), new TextConstraint(keyword,
                PatternType.wildcard, false, "en"));
        fieldQuery.setLimit(1);
        fieldQuery.setOffset(0);
        return fieldQuery;
    }
View Full Code Here

        test2.add(field, "This is the text content of a field with value2.");
        Iterable<Representation> updatedIterable = yard.update(Arrays.asList(test1, test2));
        assertNotNull(updatedIterable);

        FieldQuery query = yard.getQueryFactory().createFieldQuery();
        query.setConstraint(field, new TextConstraint(Arrays.asList("text content")));
        QueryResultList<Representation> results = yard.find(query);
        assertEquals(2, results.size());

        // fetch the light / minimal representation
        query = yard.getQueryFactory().createFieldQuery();
        query.setConstraint(field, new TextConstraint(Arrays.asList("value2")));
        results = yard.find(query);
        assertEquals(1, results.size());
        Representation result = results.iterator().next();
        assertEquals("urn:yard.test.testFieldQuery:representation.id2", result.getId());
        assertEquals(null, result.getFirst(field));
View Full Code Here

        // assertEquals(0.80, first.getFirst("http://www.iks-project.eu/ontology/rick/query/score"));

        // combine similarity with traditional filtering
        query = yard.getQueryFactory().createFieldQuery();
        query.setConstraint(similarityfield, new SimilarityConstraint("aaaa aaaa aaaa aaaa zzzz yyyy"));
        query.setConstraint(filterfield, new TextConstraint(Arrays.asList("other")));
        results = yard.find(query);
        assertEquals(1, results.size());
        it = results.iterator();
        first = it.next();
        assertEquals("urn:yard.test.testFieldQueryWithSimilarityConstraint:representation.id2", first.getId());
View Full Code Here

                 *    mappings that define no language filter
                 * b) calculate the mapped fields. Possible there are no mappings
                 *    left. Than we need not to process all the values
                 */
                Set<String> targetFields = new HashSet<String>();
                TextConstraint globalFilter = null;
                Collection<Object> globalFiltered = null;
                /*
                 * NOTE: the mappings are sorted in the way, that the most
                 *   prominent one will be at index 0. The wildcard "*" will
                 *   be always the last.
View Full Code Here

            case value:
                ValueConstraint valueConstraint = (ValueConstraint)mapping.getFilter();
                processFilter(valueConstraint,filtered,valueFactory);
                break;
            case text:
                TextConstraint textConstraint = (TextConstraint)mapping.getFilter();
                //for wildcard mappings only filter TextValues. if the mapping is
                //for a specific field filter also non text values.
                processFilter(textConstraint,filtered,!mapping.usesWildcard());
                break;
            default:
View Full Code Here

        log.debug("Process {}", namedEntity);
        FieldQuery query = site == null ? //if site is NULL use the Entityhub
                entityhub.getQueryFactory().createFieldQuery() :
                    site.getQueryFactory().createFieldQuery();
        // replace spaces with plus to create an AND search for all words in the name!
        query.setConstraint(nameField, new TextConstraint(namedEntity.getName()));// name.replace(' ', '+')));
        if (OntologicalClasses.DBPEDIA_PERSON.equals(namedEntity.getType())) {
            if (personState) {
                if (personType != null) {
                    query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(personType));
                }
View Full Code Here

        FieldQueryFactory qf = DefaultQueryFactory.getInstance();
        FieldQuery fieldQuery = qf.createFieldQuery();
        Collection<String> selectedFields = new ArrayList<String>();
        selectedFields.add(DEFAULT_AUTOCOMPLETE_SEARCH_FIELD);
        fieldQuery.addSelectedFields(selectedFields);
        fieldQuery.setConstraint(DEFAULT_AUTOCOMPLETE_SEARCH_FIELD, new TextConstraint(pattern,
                PatternType.wildcard, false, "en"));
        fieldQuery.setLimit(AUTOCOMPLETED_KEYWORD_NUMBER);
        fieldQuery.setOffset(0);

        List<String> result = new ArrayList<String>();
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.query.TextConstraint

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.