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.
-
database, data bank, DB
- 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.
-
database, data bank, DB
- 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.
-
Synonym dictionary name: Dictionary2
The following terms are registered as synonyms in synonym dictionary Dictionary2:
-
relational database, RDB, NoSQL database
-
-
Synonym dictionary name: Dictionary3
The following terms are registered as synonyms in synonym dictionary Dictionary3:
-
relational database, RDB, NoSQL database, No-SQL database, cloud database
-
- 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
-
If the search-target character string specified for scalar function CONTAINS has not been registered in the synonym dictionary, synonym search operations are not performed.
Example:
When the synonyms registered in the synonym dictionary are database, data bank, and DB, if the following SELECT statement is executed, a synonym search operation is not performed. In this case, only RDB is the search-target character string.
SELECT "TITLE" FROM "REPORTS" WHERE CONTAINS("DOCUMENTS",'SYNONYM("Dictionary1",SORTCODE("RDB"))')>0
-
While a synonym dictionary is being updated (while the adbsyndict command is being executed), you can perform synonym search operations by using the synonym dictionary being updated. Note, however, that whether the search operation uses the synonym dictionary in the state before update or after update differs depending on the timing.