Mini program scenarios

Updated at:

1. Background of mini program search

Frontend: WeChat officially provides the SearchBar plug-in, which mainly implements the frontend of the search box. Backend: Simple search is implemented in two parts: mini program search and cloud development.

  • Mini program search provides the following three APIs and does not provide product search or text search capabilities:

search.imageSearch: provides in-site product image search for mini programs. search.siteSearch: provides query capabilities for pages. search.submitPages: submits the URLs and parameter information of mini program pages so that WeChat can index the page information of mini programs in a more timely manner.

  • Cloud development

Developers can use cloud development to develop WeChat mini programs and mini games and use cloud capabilities without the need to build servers. Cloud development provides developers with complete native cloud support and WeChat service support, which minimizes backend and O&M concerns. Without building servers, developers can use the APIs provided by the platform to develop core business features, which enables fast launches and iterations. This capability is also compatible with, rather than mutually exclusive with, the cloud services that developers already use. Cloud development provides cloud functions, cloud databases, storage, and cloud calls. Search mainly relies on cloud databases. In terms of search capabilities, developers can mainly implement regular expression-based fuzzy matching. Cloud development also supports basic aggregation, geographic (GEO) search, and best practices for multi-field fuzzy search. However, the search performance and search quality are limited, and capabilities such as tokenization and query analysis (QP) are not supported.

2. Problems and requirements

In e-commerce and content industry scenarios that rely on query intent understanding, the native search service of mini programs provides only basic features and cannot meet business requirements. The resulting poor search experience directly affects business conversion.

3. Analysis of e-commerce search scenarios

  • Low input efficiency in the search box.

  • The purchase conversion rate needs to be improved.

  • Keyword stacking.

For example, the search query "Pampers boys large size pull-up diapers free shipping" is tokenized into Pampers, boys, large size, pull-up diapers, and free shipping. A single query contains multiple search keywords, and these keywords have different levels of importance: high, medium, and low.

  • Word order has little impact on semantics.

  • Category prediction.

    For example, when a user searches for "apple", the user may be looking for the fruit or the mobile phone brand.

4. Analysis of content search scenarios

  • Long-tail queries in colloquial language occur relatively frequently, keywords and content are highly diverse, and the wording of search queries varies widely in how standardized it is.

  • Content from multiple channels is aggregated.

  • The search engine must have strong semantic understanding capabilities.

  • Some scenarios are highly vertical and specialized.

    Examples: a. The query "recommended science fiction novels for men" involves many keywords and aggregates content from multiple channels, and word order has little impact on semantics. b. The query "how to treat a cough with phlegm in babies under 3 years old" is highly specialized and requires more precise relevance of search results.

5. OpenSearch solution

tu

Requirement

OpenSearch

Environment setup

Purchase an application and start the integration configuration.

Data ingestion

Supports multiple data ingestion methods, such as RDS, ODPS, POLARDB, and API/SDK.

Tokenization

Provides built-in Alibaba natural language processing (NLP) tokenization, including analyzers for general industries, the e-commerce industry, and the IT industry, as well as Chinese and English analyzers, which deliver higher recall and precision.

Query semantic understanding

- Spelling correction: corrects misspelled query terms. - Synonyms: expands queries with Chinese-English equivalents and synonyms. - Term weight: measures the importance of each term in a query within the text and quantifies it as a weight. - Named entity recognition: in the e-commerce industry, mainly recognizes entity types such as brands, categories, designs, and styles to improve recall and accuracy.

Sorting

- Category prediction: predicts the category of results that a user wants based on the query terms and works with sort expressions to rank results that better match the search intent higher. - Two-round relevance sorting: the first round is rough sort, which selects relevant documents from the set of matched documents. The second round is fine sort, which performs finer filtering on the rough sort results. - Popularity model: quantifies the static quality and popularity of each product, and continuously trains on statistics to generate popularity scores. This helps build a more refined sorting model that precisely meets search requirements.

Drop-down suggestions

Intelligently recommends candidate queries while a user enters query terms, helping the user find the desired content as quickly as possible.

Top searches and hints

- Top searches: obtains the 10 most popular search phrases or topics based on search popularity and displays them below the search box. - Hints: high-quality queries that are displayed directly in the search box when a user has not entered a search term.

Algorithm features

Provides a variety of built-in, mature advanced algorithm features.

Elastic scaling

Simple operations, smooth scale-out and scale-in, and changes that take effect immediately.

O&M costs

Zero O&M and no deployment required.

Development and deployment costs

Ready to use out of the box. One engineer can build the basic service in 0.5 to 1 day.

6. Integrate a mini program with OpenSearch in just 2 steps

6.1 Data ingestion

  • Data source ingestion: To ingest a data source, purchase an RDS instance (or a PolarDB instance or another data source) on Alibaba Cloud and connect it to OpenSearch. To connect a mini program to OpenSearch, you only need the query API or SDK. 

  • API/SDK integration: Integrating a mini program is no different from integrating an app or a web product. WeChat mini programs have their own set of coding conventions, but you still use the OpenSearch SDK or API to obtain results from OpenSearch.

6.2 Search service integration

  • Call an external API in the JavaScript code of the mini program to obtain search results.

  • Integration is commonly implemented by using Elasticsearch (ES), Solr, third-party cloud services, or other methods.

  • Example:

    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) {},
       })