public List < WbSearchEntitiesResult > wbSearchEntities ( String search , String language , Boolean strictLanguage , String type , Long limit , Long offset ) throws MediaWikiApiErrorException { Map < String , String > parameters = new HashMap < String , String > ( ) ; parameters . put ( ApiConnection . PARAM_ACTION , "wbsearchentities" ) ; if ( search != null ) { parameters . put ( "search" , search ) ; } else { throw new IllegalArgumentException ( "Search parameter must be specified for this action." ) ; } if ( language != null ) { parameters . put ( "language" , language ) ; } else { throw new IllegalArgumentException ( "Language parameter must be specified for this action." ) ; } if ( strictLanguage != null ) { parameters . put ( "strictlanguage" , Boolean . toString ( strictLanguage ) ) ; } if ( type != null ) { parameters . put ( "type" , type ) ; } if ( limit != null ) { parameters . put ( "limit" , Long . toString ( limit ) ) ; } if ( offset != null ) { parameters . put ( "continue" , Long . toString ( offset ) ) ; } List < WbSearchEntitiesResult > results = new ArrayList <> ( ) ; try { JsonNode root = this . connection . sendJsonRequest ( "POST" , parameters ) ; JsonNode entities = root . path ( "search" ) ; for ( JsonNode entityNode : entities ) { try { JacksonWbSearchEntitiesResult ed = mapper . treeToValue ( entityNode , JacksonWbSearchEntitiesResult . class ) ; results . add ( ed ) ; } catch ( JsonProcessingException e ) { LOGGER . error ( "Error when reading JSON for entity " + entityNode . path ( "id" ) . asText ( "UNKNOWN" ) + ": " + e . toString ( ) ) ; } } } catch ( IOException e ) { LOGGER . error ( "Could not retrive data: " + e . toString ( ) ) ; } return results ; }
Executes the API action wbsearchentity for the given parameters . Searches for entities using labels and aliases . Returns a label and description for the entity in the user language if possible . Returns details of the matched term . The matched term text is also present in the aliases key if different from the display label .