...
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
.
Code Block | ||
---|---|---|
| ||
<?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
.
Code Block | ||
---|---|---|
| ||
<?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> |
Code Block | ||
---|---|---|
| ||
<?xml version="1.0"?>
<methodCall>
<methodName>termwebapi2.getSourceLanguage</methodName>
<params>
<param><value><string>123456789abc</string></value></param>
</params>
</methodCall> |
Response:
Code Block | ||
---|---|---|
| ||
<?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.
Info |
---|
At most 1000 entries are returned by a call to |
Example: Search for the term "fish"
Code Block | ||
---|---|---|
| ||
<?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:
Code Block | ||
---|---|---|
| ||
<?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.
Anchor | ||||
---|---|---|---|---|
|
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
Code Block | ||
---|---|---|
| ||
<?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
Code Block | ||
---|---|---|
| ||
<?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:
Code Block | ||
---|---|---|
| ||
<?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> |
Getting concept and term entries
For retrieving concepts and terms the following custom methods exist:
Method | Returns | Return type | Description |
---|---|---|---|
getConceptEntry(sessionID, objID) | A concept entry | struct | Returns the concept entry with specified oid from current dictionary. Same as generic method call getObject(sessionID, 'conceptentry', objID) |
getConceptEntryByCID(sessionID, conceptID) | A concept entry | struct | Returns the concept entry with specified concept ID from current dictionary. |
getTermEntry(sessionID, objID) | A term entry | struct | Returns the term entry with specified oid from current dictionary. Same as generic method call getObject(sessionID, 'termentry', objID) |
getTermEntryByTID(sessionID, termID) | A term entry | struct | Returns the term entry with specified term ID from current dictionary. |
getTermEntries(sessionID, searchCondition, targetLang) | List of term entries | array | Returns the matching term entries for the specified search condition and translated into the specified target language. |
Filters
For more advanced search functionality you can use search filters. With the generic methods getAll
, getObject
, getObjectByName
, getSelected
and setSelected
you can retrieve existing filters and set a filter to be applied when searching.
Creating and updating filters
To create a new filter for search, you construct a data object for filter, including the filter criteria for the fields you wish to include, and then call the create
method. No value is needed for id
fields in Filter
or FilterCriteria
.
To update, you modify the filter criteria in an existing method, and then call the update
method.
Info |
---|
To find the IDs for dictionary and fields to include in the data objects you retrieve the |
Remember to call setSelected
to apply the new or updated filter.