use of org.wikidata.query.rdf.tool.wikibase.SearchResponse.SearchResult in project wikidata-query-rdf by wikimedia.
the class WikibaseRepository method firstEntityIdForLabelStartingWith.
/**
* Get the first id with the provided label in the provided language.
*
* @throws RetryableException thrown if there is an error communicating with
* wikibase
*/
public String firstEntityIdForLabelStartingWith(String label, String language, String type) throws RetryableException {
URI uri = uris.searchForLabel(label, language, type);
log.debug("Searching for entity using {}", uri);
try {
SearchResponse result = checkApi(getJson(new HttpGet(uri), SearchResponse.class));
List<SearchResult> resultList = result.getSearch();
if (resultList.isEmpty()) {
return null;
}
return resultList.get(0).getId();
} catch (IOException e) {
throw new RetryableException("Error searching for page", e);
}
}
Aggregations