All Products
Search
Document Center

Mini programs

Last Updated: Sep 09, 2021

1. Background information

WeChat provides the SearchBar plug-in, which is used as the frontend of a search box. Simple searches are performed at the backend. The backend supports mini-program searches and cloud-based development.

  • Mini-program searches

You can call the following operations to perform mini-program searches. However, these operations cannot be called to search for commodities or text. search.imageSearch: searches for commodity images on a specific website of a mini program. search.siteSearch: searches for a specific website. search.submitPages: submits the URL and parameter information of a specific page of the mini program so that WeChat can obtain the information at the earliest opportunity.

  • Cloud-based development

The cloud-based development feature allows you to develop mini programs and mini games in WeChat. You can use the cloud-based capabilities without the need to build servers. The cloud-based development feature provides full support for cloud native services and WeChat services. It reduces backend and O&M processes and can be used without the need to build servers. You can call the operations provided by the platform to develop core business. This way, you can publish and iterate your business with ease. In addition, you can use the cloud-based capabilities without affecting the existing cloud services. The cloud-based development feature allows you to use cloud functions and cloud databases, store data, and call cloud operations. Searches are performed based on cloud databases. In the search process, you can develop the fuzzy match process based on regular expressions. For example, you can perform basic aggregation operations, geographical location-based searches, and multi-field fuzzy match. However, the search performance and effect are limited. Analysis and query analysis are not supported.

2. Issues

For searches in query intent-based scenarios such as E-commerce and content industries, the native search capabilities provided by a mini program are insufficient to meet business requirements and may result in poor search experience. Therefore, business is affected.

3. Characteristics of searches in E-commerce scenarios

  • The efficiency of using a search box to enter search queries is low.

  • Demands increase the business conversion rate.

  • Keywords pile up.

For example, the search query is: "Pampers Boy Large-size Diaper Delivery-free". After analysis, the following terms are obtained: Pampers, Boy, Large-size, Diaper, and Delivery-free. A single search query contains several keywords with priorities from low to high.

  • The term order has little impact on the semantic meaning.

  • Category prediction is complex.

    For example, the search query "Apple" may indicate a type of fruit or a mobile phone brand.

4. Characteristics of searches in the content industry

  • In the content industry, colloquial long-tail search queries are often used. In addition, users may search for diversified keywords and content, and the standardization of search queries entered by users varies from person to person.

  • The content of multiple channels is aggregated together.

  • Search engines must have good performance in semantic understanding.

  • Specific search queries are highly professional.

    Example a: The following search query is entered: "Science fictions suitable for boys to read". This search query contains multiple keywords and aggregates content from different channels. In addition, the word order has little impact on the semantic meaning. Example b: The following search query is entered: "How to deal with the expectoration of a baby less than three". This is a highly professional query, which demands that the returned results must be highly relevant.

5. OpenSearch solutions

eng

Item

Solution

Environment setup

Allows you to purchase an application to configure a mini program.

Data connection

Supports data connection by configuring ApsaraDB RDS, MaxCompute, and PolarDB data sources or using APIs or SDKs.

Analysis

Provides built-in Alibaba Cloud natural language processing (NLP) analysis tools. You can use the tools to analyze words in general industries, E-commerce industry, and IT industry, or analyze Chinese or English words. This enlarges the retrieval scope and improves the precision rate.

Semantic understanding

Provides the spelling correction, synonym configuration, term weight analysis, and named entity recognition (NER) features. Spelling correction: helps you correct spelling errors in search queries. Synonym configuration: adds synonyms for Chinese or English terms. Term weight analysis: uses weights to quantify the importance of each term in a search query. NER: recognizes the entity categories in the E-commerce industry, such as brand, category, and style. This improves the retrieval rate and accuracy.

Sorting

Category prediction: predicts the category in which the search query that you entered falls. Then, sort expressions are used so that the results that better meet your requirements can be ranked in the front. Relevance-based sort: consists of a rough sort and a fine sort. In the rough sort process, relevant documents are selected from all documents that are retrieved. In the fine sort process, the rough sort results are finely sorted. Popularity model: quantifies the static quality and popularity degree of each commodity. Then, continuous training is conducted and data is collected to generate popularity scores. This way, a more fine-grained sort model can be constructed to precisely meet your search requirements.

Drop-down suggestion

Intelligently displays recommended search queries when you enter a query. This expedites the process of finding the desired query.

Top searches and hints

Top searches: the top 10 top searches or topics that are displayed below the search box. Hints: the high-quality queries displayed in the search box before you enter search queries.

Algorithm feature

Provides multiple advanced algorithms that are embedded in OpenSearch.

Scalability feature

Allows you to perform smooth scale-in or scale-out operations with ease. These operations immediately take effect.

O&M costs

Frees you from O&M and deployment costs.

Development costs

Provides out-of-the-box services that allow an engineer to set up basic services within half or one day.

6. Connect a mini program to OpenSearch

6.1 Data connection

  • Connect to a data source: Purchase an ApsaraDB RDS or a PolarDB data source in Alibaba Cloud, and then connect the data source to OpenSearch. To connect a mini program to OpenSearch, you need only to use APIs or SDKs for data queries.

  • Use APIs or SDKs: The connection of a mini program to OpenSearch is similar to that of an application or a web page to OpenSearch. A WeChat mini program uses its dedicated code conventions. However, you must use APIs or SDKs to obtain the search results in OpenSearch.

6.2 Connection to OpenSearch

  • To obtain the search results, use JavaScript to call external API operations in the mini program.

  • You can use Elasticsearch, Solr, or a third-party cloud service to connect to OpenSearch.

  • Sample code:

    wx.request({
         url: '',
         data: {SercherValue:that.data.inputValue,
             SercherTypeNum:that.data.SercherTypeNum,
             typeItem:that.data.typeItem },
         header: {},
         method: '',
         dataType: '',
         success: function(res) {},
         fail: function(res) {},
         complete: function(res) {},
       })