This section describes how to search for concept and terms via TermWeb API.
Selecting dictionary, section and domain
Searching via the API is similar to searching in TermWeb directly. You need to select a dictionary, one or more sections, and optionally a set of domains. The selections are saved when the user's session is closed (i.e. by logging out), and applied again when the same user logs in.
Selecting dictionary
Selecting which dictionary to search in is done by the generic method setSelected
.
<?xml version="1.0"?> <methodCall> <methodName>termwebapi2.setSelected</methodName> <params> <param><value><string>123456789abc</string></value></param> <param><value><string>dictionary</string></value></param> <param><value><string>312</string></value></param> </params> </methodCall>
Response:
<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param><value><i4>0</i4></value></param> </params> </methodResponse>
The ID for the dictionary can be retrieved from the Dictionary data object retrieved from getAll
or getSelected
methods. It is also possible to find an object by its name, using the getObjectByName
method. Only readable dictionaries for the user are returned, and the API will give authorization error (1100) if a non-readable dictionary is selected.
Selecting sections or domains
By default, all readable sections are selected in a dictionary. A single section, or a list of sections, can be selected with setSelected
, and all sections are selected by calling setAllSelected
.
<?xml version="1.0"?> <methodCall> <methodName>termwebapi2.setSelected</methodName> <params> <param><value><string>123456789abc</string></value></param> <param><value><string>section</string></value></param> <param><value><array><data> <value><string>7522308</string></value> <value><string>1184008</string></value> <value><string>244004</string></value> </data></array></value></param> </params> </methodCall>
Same methods apply for selecting domains. When retrieving a domain via getObjectByName
method, the domain tree is searched top-down, and the first domain with matching name is returned.
Selecting language
Selecting the source language can also be done with setting the language's ID in setSelected
, but an easier way is to use setSourceLanguage
and the language code. The currently selected language code can be retrieved with getSourceLanguage
.
<?xml version="1.0"?> <methodCall> <methodName>termwebapi2.setSourceLanguage</methodName> <params> <param><value><string>123456789abc</string></value></param> <param><value><string>eng</string></value></param> </params> </methodCall>
<?xml version="1.0"?> <methodCall> <methodName>termwebapi2.getSourceLanguage</methodName> <params> <param><value><string>123456789abc</string></value></param> </params> </methodCall>
Response:
<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param><value>eng</value></param> </params> </methodResponse>
Searching terms
With the method getIndexTerms
you can retrieve a list of IndexTerm objects, corresponding to the items in the termlist in the GUI. From the index terms you can then retrieve the full concept or term objects. To getIndexTerms
you can specify a search expression which filters the result. An empty search expression returns the full list.
At most 1000 entries are returned by a call to getIndexTerms
. To retrieve more, do subsequent calls to getIndexTerms
and set the fromPos
parameter in the Search condition struct.
Example: Search for the term "fish"
<?xml version="1.0"?> <methodCall> <methodName>termwebapi2.getIndexTerms</methodName> <params> <param><value><string>123456789abc</string></value></param> <param><value><string>fish</string></value></param> </params> </methodCall>
Response:
<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param><value><array><data><value> <struct> <member><name>__objtype</name><value>IndexTerm</value></member> <member><name>term</name><value>fish</value></member> <member><name>conceptEntryID</name><value>436</value></member> <member><name>termEntryID</name><value>437</value></member> </struct> </value></data></array></value></param> </params> </methodResponse>
You can also use wildcards (asterisk for any string, question mark for any single character) in the search expression.
Search condition struct
You can also pass a struct as argument to getIndexTerms
. The struct consists of the search expression and an integer specifying from which index in the termlist the returned result should start.
Example: Search for all terms containg "fish" but skip the five first results
<?xml version="1.0"?> <methodCall> <methodName>termwebapi2.getIndexTerms</methodName> <params> <param><value><string>123456789abc</string></value></param> <param><value><struct> <member><name>searchExp</name><value><string>*fish*</string></value></member> <member><name>fromPos</name><value><int>5</int></value></member> </struct></value></param> </params> </methodCall>
Translating results
It is also possible to return the index terms in a target language. By specifying a target language code after the search condition struct, the result contains all terms in the target language, from the concepts corresponding to the found index terms in the source language.
Example: Search for the term "fish" and return result in French
<?xml version="1.0"?> <methodCall> <methodName>termwebapi2.getIndexTerms</methodName> <params> <param><value><string>123456789abc</string></value></param> <param><value><struct> <member><name>searchExp</name><value><string>fish</string></value></member> <member><name>fromPos</name><value><int>0</int></value></member> </struct></value></param> <param><value><string>fra</string></value></param> </params> </methodCall>
Response:
<?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param><value><array><data><value> <struct> <member><name>__objtype</name><value>IndexTerm</value></member> <member><name>term</name><value>poisson</value></member> <member><name>conceptEntryID</name><value>436</value></member> <member><name>termEntryID</name><value>440</value></member> </struct> </value></data></array></value></param> </params> </methodResponse>