Hitachi

Hitachi Advanced Database Setup and Operation Guide


11.16.2 Performing synonym search operations

Perform synonym search operations by using the scalar function CONTAINS. For details about the scalar function CONTAINS, see CONTAINS in the manual HADB SQL Reference.

Organization of this subsection

(1) Basic search example

In this example, a synonym search operation is performed by using synonym dictionary Dictionary1. The following terms are registered as synonyms in synonym dictionary Dictionary1.

Example:

In the DOCUMENTS column, document data is stored. In this example, the names (in the TITLE column) of the document data that contains any of database, data bank, or DB are retrieved.

SQL statement to be executed

SELECT "TITLE" FROM "REPORTS"
    WHERE CONTAINS("DOCUMENTS",'SYNONYM("Dictionary1","data bank")')>0
Explanation:

In scalar function CONTAINS, the synonym dictionary name (Dictionary1) and one of the synonyms registered in Dictionary1 (data bank) are specified. If you execute the preceding SQL statement, the names (in the TITLE column) of certain document datasets are returned as the search result. Such document datasets contain, in their sentence information, any of the synonyms (database, data bank, and DB) registered in the same synonym group in the synonym dictionary.

Note

For details about how to check the synonyms registered in the synonym dictionary, see 11.16.3 Checking the synonyms registered in a synonym dictionary.

(2) Search example in which correction search is applied

In this example, a synonym search operation is performed by using synonym dictionary Dictionary1, which supports correction search. The following terms are registered as synonyms in synonym dictionary Dictionary1.

Example:

In the DOCUMENTS column, document data is stored. In this example, the names (in the TITLE column) of the document datasets that contain any of database, data bank, DB, DATABASE, Data bank, or db are retrieved.

SQL statement to be executed

SELECT "TITLE" FROM "REPORTS"
    WHERE CONTAINS("DOCUMENTS",'SYNONYM("Dictionary1",SORTCODE("data bank"))')>0
Explanation:

In the scalar function CONTAINS, the synonym dictionary name (Dictionary1) and one of the synonyms registered in Dictionary1 (data bank) are specified. If you execute the preceding SQL statement, the names (in the TITLE column) of certain document datasets are returned as the search result. Such document datasets contain, in their sentence information, any of the synonyms (database, data bank, and DB) registered in the same synonym group in the synonym dictionary.

Also, the names (in the TITLE column) of the document datasets that contain the term DATABASE, Data bank, or db are also returned as the search result. This is because the function of correction search is working.

(3) Search example in which two synonym dictionaries are used

The following provides a search example in which two synonym dictionaries are used.

Example:

In this example, the names (in the TITLE column) of the document datasets that satisfy all the following conditions are retrieved:

  • Document datasets stored in the DOCUMENTS column contain any of the terms relational database, RDB, and NoSQL database.

  • Document dataset names stored in the TITLE column contain any of the terms relational database, RDB, NoSQL database, No-SQL database, and cloud database.

SELECT "TITLE" FROM "REPORTS"
    WHERE CONTAINS("DOCUMENTS",'SYNONYM("Dictionary2","RDB")')>0
      AND CONTAINS("TITLE",'SYNONYM("Dictionary3","RDB")')>0

(4) Notes