Full-Text Search
Example DB Table
smartPanda.public.product
CREATE TABLE `product` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255),
`description` text,
PRIMARY KEY (`id`)
);
Take MySQL for example,MySQL provides an ngram full-text parser that supports Chinese, Japanese, and Korean (CJK).
Creating a FULLTEXT Index that Uses the ngram Parser.
ALTER TABLE `smart_panda`.`product`
ADD FULLTEXT INDEX `fts_description` (`description`) WITH PARSER ngram;
Full-text search for the fields specified in the method name
db.schema.table.searchBy*
returns the filtered and sorted list page and the total number of rows { data: [], total: int }
according to the fields specified in the method name and the keywords specified in the full-text search parameters.
API searchBy*
Example Request
{
"method": "smartPanda.public.product.searchByDescription",
"params": ["Car"]
}
Example response, some parts omitted
{
"data": [
{
"id": 17400,
"name": "Car a",
"description": "Car a"
},
{
"id": 4164,
"name": "b",
"description": "b car"
},
{
"id": 17398,
"name": "Car c",
"description": "Car c"
},
{
"id": 17399,
"name": "Car d",
"description": "Car d"
},
{
"id": 5166,
"name": "e car e",
"description": "Car e"
}
],
"total": 31
}