Set<UriRef> includeFields,
List<String> search,
String[] languages,
Integer limit) 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 && limit > 0){
query.setLimit(limit);
} else if(this.limit != null){
query.setLimit(this.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);
}
Collection<Entity> entities = new ArrayList<Entity>(results.size());
for(Representation result : results){
entities.add(new EntityhubEntity(result));
}