/** * Uses the public API to clone the state of this instance to the instance provided as parameter. * * @param <C> * An implementation of the FieldQuery interface * @param copyTo * An instance to copy the state of this on. * @return The parsed instance */ public <C extends FieldQuery> C copyTo(C copyTo) { copyTo.removeAllConstraints(); copyTo.removeAllSelectedFields(); for (Entry<String,Constraint> entry : queryConstraint.entrySet()) { // we need not to copy keys or values, because everything is // immutable copyTo.setConstraint(entry.getKey(), entry.getValue()); } copyTo.addSelectedFields(selected); copyTo.setLimit(limit); copyTo.setOffset(offset); return copyTo; }
/** * Uses the public API to clone the state of this instance to the instance provided as parameter. * * @param <C> * An implementation of the FieldQuery interface * @param copyTo * An instance to copy the state of this on. * @return The parsed instance */ public <C extends FieldQuery> C copyTo(C copyTo) { copyTo.removeAllConstraints(); copyTo.removeAllSelectedFields(); for (Entry<String,Constraint> entry : queryConstraint.entrySet()) { // we need not to copy keys or values, because everything is // immutable copyTo.setConstraint(entry.getKey(), entry.getValue()); } copyTo.addSelectedFields(selected); copyTo.setLimit(limit); copyTo.setOffset(offset); return copyTo; }
query.setLimit(limit);
query.setLimit(20);//TODO make configurable query.setConstraint(field, new TextConstraint(search, languages)); return query;
@Override public Collection<? extends Representation> lookup(String field, Set<String> includeFields, List<String> search, String... languages) throws IllegalStateException { //build the query and than return the result Site site = getSearchService(); if(site == null){ throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available"); } FieldQuery query = EntitySearcherUtils.createFieldQuery(site.getQueryFactory(), field, includeFields, search, languages); if(limit != null){ query.setLimit(limit); } QueryResultList<Representation> results; try { results = site.find(query); } catch (SiteException e) { throw new IllegalStateException("Exception while searchign for "+ search+'@'+Arrays.toString(languages)+"in the ReferencedSite "+ site.getId(), e); } return results.results(); }
query.setLimit(jQuery.getInt("limit")); } catch (JSONException e) { parsingErrorMessages.append('\n');
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); }
query.setLimit(Integer.valueOf(DEFAULT_MAX_SELECT)); QueryResultList<String> results; try {
query.setLimit(20);//TODO make configurable
query.setLimit(Math.max(20, this.numSuggestions * 3));
addTypeConstraint(rQuery, query); addPropertyConstraints(rQuery, query); query.setLimit(query.getLimit()); QueryResultList<Representation> results = performQuery(siteId, query); List<JSONObject> jResultList = new ArrayList<JSONObject>(results.size());
/** * Gets an Entity from the configured {@link Site} based on the NER text and type. * * @param ner * @param language * @return * @throws EngineException */ private Entity lookupEntity(Span ner, String language) throws EngineException { Site site = getReferencedSite(); FieldQueryFactory queryFactory = site == null ? entityHub.getQueryFactory() : site.getQueryFactory(); FieldQuery query = queryFactory.createFieldQuery(); Constraint labelConstraint; String namedEntityLabel = ner.getSpan(); labelConstraint = new TextConstraint(namedEntityLabel, false, language, null); query.setConstraint(RDFS_LABEL.getUnicodeString(), labelConstraint); query.setConstraint(RDF_TYPE.getUnicodeString(), new ReferenceConstraint(ner.getAnnotation(NlpAnnotations.NER_ANNOTATION).value().getType() .getUnicodeString())); query.setLimit(1); QueryResultList<Entity> results = site == null ? // if site is NULL entityHub.findEntities(query) : // use the Entityhub site.findEntities(query); // else the referenced site if (results.isEmpty()) return null; // We set the limit to 1 so if it found anything it should contain just 1 entry return results.iterator().next(); }