Search services are everywhere, such as Google search in daily life, wiki search in work, and product search in shopping. Data in such scenarios is generally large in size and structured and has more reads than writes. However, due to their transaction characteristics, traditional databases cannot well utilize space in search scenarios and are slow in full-text searches (such as LIKE statement). Elasticsearch thus came into being.
Elasticsearch is an open-source search engine widely used in full-text search. It can quickly index, search, and analyze a massive amount of text data. Tencent Cloud ES is a highly available and scalable cloud-hosted Elasticsearch service. It well supports both structured and non-structured data and provides easy-to-use RESTful APIs and clients in multiple languages to help you quickly build stable search services.
This document describes how to use ES and SCF to quickly build a search service with the following page by referring to the official Tencent Cloud ES documentation.
Purchase an ES cluster. The cluster scale is subject to the search service QPS and data size of the stored documents. For more information, see Evaluation of Cluster Specification and Capacity Configuration.
Use the free SCF tool provided by Tencent Cloud to deploy the frontend page and backend service of the search service.
index.py
and index.html
files:es_endpoint
in index.py
to the private network address of your ES cluster, such as http://10.0.3.14:9200
.es_password
in index.py
to the password of ES Platinum Edition; if your ES is not Platinum Edition, leave it unchanged.server_name
in index.html
to the name of the created SCF function, which is myserver
by default.
Note:
es_corpus_0126
is used as the index name by default in the sample. Make sure that the index is not used by other businesses. To modify it, modify thees_index
variable inindex.py
.
Stopwords will not be searched by ES, and words in the custom dictionary will be retained during segmentation. In the previous sample, the default stopword dictionary and custom dictionary are imported. You can also import your own stopword and custom dictionaries in Plugin List > Update Dictionary on the ES cluster details page.
To configure synonyms, you need to specify them when creating an index. Synonyms in Solr and WordNet formats are supported. For more information on the format, see Solr synonyms.
Was this page helpful?