return null; } else { return new TextConstraint((String)null,langs);
String intend) { boolean filterAdded = false; boolean isTextValueConstraint = constraint.getTexts() != null && !constraint.getTexts().isEmpty(); if (constraint.getPatternType() == PatternType.regex) { queryString.append(" \n").append(intend).append(" FILTER("); filterAdded = true; addRegexFilter(queryString, var, constraint.getTexts(), constraint.isCaseSensitive()); } else { queryString.append(". \n ").append(intend); queryString.append(String.format("?%s bif:contains '%s'", var, createFullTextQueryString(constraint.getTexts()))); } else if (SparqlEndpointTypeEnum.LARQ == endpointType) { queryString.append(". \n ").append(intend); queryString.append(String.format( "?%s <http://jena.hpl.hp.com/ARQ/property#textMatch> '%s'", var, createFullTextQueryString(constraint.getTexts()))); } else { queryString.append(" \n").append(intend).append(" FILTER("); filterAdded = true; if (constraint.getPatternType() == PatternType.none) { constraint.getTexts().size()); for (String textConstraint : constraint.getTexts()) { if (textConstraint != null && !textConstraint.isEmpty()) { regexQueryTexts.add(PatternUtils.word2Regex(textConstraint)); addRegexFilter(queryString, var, regexQueryTexts, constraint.isCaseSensitive());
if(textConstraint.getTexts() != null){ log.warn("Filtering based on values is not implemented"); Set<String> langs = textConstraint.getLanguages(); boolean acceptDefaultLanguage = textConstraint.getLanguages().contains(null); for(Iterator<Object> it = values.iterator();it.hasNext();){ Object value = it.next();
throw new IllegalArgumentException(message.toString()); constraint = new TextConstraint(textConstraints, patternType,caseSensitive, languages == null?null:languages.toArray(new String[languages.size()])); constraint.setProximityRanking(jConstraint.optBoolean("proximityRanking", false));
private static void serializeConstraint(StringBuilder builder,TextConstraint constraint){ builder.append("| @="); boolean first = true; for(String lang : constraint.getLanguages()){ if(first){ first = false; } else { builder.append(';'); } builder.append(lang); } } private static void serializeConstraint(StringBuilder builder,ValueConstraint constraint){
TextConstraint tc = new TextConstraint(search, languages); tc.setProximityRanking(true); //STANBOL-1104 query.setConstraint(field.getUnicodeString(),tc); return query;
if(textConstraint.getTexts() != null){ log.warn("Filtering based on values is not implemented"); Set<String> langs = textConstraint.getLanguages(); boolean acceptDefaultLanguage = textConstraint.getLanguages().contains(null); for(Iterator<Object> it = values.iterator();it.hasNext();){ Object value = it.next();
private static void serializeConstraint(StringBuilder builder,TextConstraint constraint){ builder.append("| @="); boolean first = true; for(String lang : constraint.getLanguages()){ if(first){ first = false; } else { builder.append(';'); } builder.append(lang); } } private static void serializeConstraint(StringBuilder builder,ValueConstraint constraint){
return null; } else { return new TextConstraint((String)null,langs);
String intend) { boolean filterAdded = false; boolean isTextValueConstraint = constraint.getTexts() != null && !constraint.getTexts().isEmpty(); if (constraint.getPatternType() == PatternType.regex) { queryString.append(" \n").append(intend).append(" FILTER("); filterAdded = true; addRegexFilter(queryString, var, constraint.getTexts(), constraint.isCaseSensitive()); } else { queryString.append(". \n ").append(intend); queryString.append(String.format("?%s bif:contains '%s'", var, createFullTextQueryString(constraint.getTexts()))); } else if (SparqlEndpointTypeEnum.LARQ == endpointType) { queryString.append(". \n ").append(intend); queryString.append(String.format( "?%s <http://jena.hpl.hp.com/ARQ/property#textMatch> '%s'", var, createFullTextQueryString(constraint.getTexts()))); } else { queryString.append(" \n").append(intend).append(" FILTER("); filterAdded = true; if (constraint.getPatternType() == PatternType.none) { constraint.getTexts().size()); for (String textConstraint : constraint.getTexts()) { if (textConstraint != null && !textConstraint.isEmpty()) { regexQueryTexts.add(PatternUtils.word2Regex(textConstraint)); addRegexFilter(queryString, var, regexQueryTexts, constraint.isCaseSensitive());
/** * @param rQuery * @param query */ private void addNameConstraint(ReconcileQuery rQuery, FieldQuery query) { //maybe an other column was also mapped to the NAME_FIELD property Collection<ReconcileValue> additionalValues = rQuery.removeProperty(NAME_FIELD); List<String> values; if(additionalValues == null){ values = Collections.singletonList(rQuery.getQuery()); } else { values = new ArrayList<String>(additionalValues.size()+1); values.add(rQuery.getQuery()); for(ReconcileValue value : additionalValues){ if(value != null && value.getValue() instanceof String){ values.add((String)value.getValue()); } } } query.setConstraint(NAME_FIELD, new TextConstraint(values)); } /**
if(textConstraint.isProximityRanking() != null){ constraintValue.setProperty(QueryConst.PHRASE_QUERY_STATE, textConstraint.isProximityRanking()); } else { for(String text : textConstraint.getTexts()){ constraintValue.getValues().add(indexValueFactory.createIndexValue( valueFactory.createText(text))); new IndexField(indexConstraint.getPath(), IndexDataTypeEnum.TXT.getIndexType(), textConstraint.getLanguages())); switch (textConstraint.getPatternType()) { case none: indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue); default: indexConstraint.setInvalid(String.format( "PatterType %s not supported for Solr Index Queries!", textConstraint.getPatternType()));
query.setConstraint(field, new TextConstraint(name, PatternType.wildcard, false)); } else { query.setConstraint(field, new TextConstraint(name, PatternType.wildcard, false, language));
if(textConstraint.isProximityRanking() != null){ constraintValue.setProperty(QueryConst.PHRASE_QUERY_STATE, textConstraint.isProximityRanking()); } else { for(String text : textConstraint.getTexts()){ constraintValue.getValues().add(indexValueFactory.createIndexValue( valueFactory.createText(text))); new IndexField(indexConstraint.getPath(), IndexDataTypeEnum.TXT.getIndexType(), textConstraint.getLanguages())); switch (textConstraint.getPatternType()) { case none: indexConstraint.setFieldConstraint(IndexConstraintTypeEnum.EQ, constraintValue); default: indexConstraint.setInvalid(String.format( "PatterType %s not supported for Solr Index Queries!", textConstraint.getPatternType()));
query.setConstraint(field, new TextConstraint(search, languages)); return query;
case text: TextConstraint textConstraint = (TextConstraint) constraint; Collection<String> languages = textConstraint.getLanguages(); if (languages != null && !languages.isEmpty()) { if(languages.size() == 1){ jConstraint.put("patternType", textConstraint.getPatternType().name()); if (textConstraint.getTexts() != null && !textConstraint.getTexts().isEmpty()) { if(textConstraint.getTexts().size() == 1){ //write a string jConstraint.put("text", textConstraint.getTexts().get(0)); } else { //write an array jConstraint.put("text", textConstraint.getTexts()); if(textConstraint.isCaseSensitive()){ jConstraint.put("caseSensitive", true); if(textConstraint.isProximityRanking() != null){ jConstraint.put("proximityRanking", textConstraint.isProximityRanking());
protected QueryResultList<Entity> query(Site dbpediaSite, String savedEntityLabel, String language, String extractionContext) throws SiteException { FieldQuery query = dbpediaSite.getQueryFactory().createFieldQuery(); if (savedEntityLabel != null && !savedEntityLabel.isEmpty()) { Constraint labelConstraint; if (language != null) { labelConstraint = new TextConstraint(savedEntityLabel, false, language, null); } else { labelConstraint = new TextConstraint(savedEntityLabel, false); } // TODO: what happens if a recommendation was not based on rdfs:label? query.setConstraint(RDFS_LABEL.getUnicodeString(), labelConstraint); } else { log.warn("parsed label {} was empty or NULL. Will use Similarity constraint only!", savedEntityLabel); } query.setConstraint(SpecialFieldEnum.fullText.getUri(), new SimilarityConstraint(extractionContext)); query.setLimit(25); return dbpediaSite.findEntities(query); }
fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); fieldMapper.addMapping(new FieldMapping(new TextConstraint( (String)null, langs.toArray(new String[langs.size()]))));
query.setConstraint("urn:field3", new TextConstraint("\"quote",PatternType.none, true, "en", null));
query.setConstraint(property.getName(), new TextConstraint(texts)); if (ids.size() != propertyEntry.getValue().size()) { log.info("Only some of the parsed values of the field {} are" TextConstraint textConstraint = new TextConstraint(fullText); query.setConstraint(SpecialFieldEnum.fullText.getUri(), textConstraint);