Introduction to the category prediction feature

更新时间:
复制 MD 格式

Search results ranked purely by text relevance often miss what users actually want. When a user searches for "Bright," they are more likely looking for dairy products than rice — but a text-only ranker cannot capture that intent. Category prediction solves this by training a model on historical search and click data to learn the relevance between queries and product categories, then using that relevance score to adjust rankings at sort time.

When a sort expression references the category relevance score, commodities in high-relevance categories rank higher. This lets you surface the most commercially relevant results without manually tuning sort weights for every query.

How it works

Category prediction trains a model that measures relevance between a search query and each commodity category. The model draws on three data sources:

Data sourceHow to provide it
Historical search queriesAdd the raw_query parameter to search requests
Category and commodity dataSpecify fields in the application; category ID and commodity title are required
Click behavioral dataInstrument the application to report click events

OpenSearch supports two training modes depending on whether behavioral data is available.

Training with behavioral data

Use this mode when click data is uploaded and meets the training thresholds. At training start, OpenSearch automatically checks that the data meets required quantity, quality, and integrity criteria.

The training pipeline runs these steps:

  1. Generate sample data from historical search queries and category information; use behavioral data to label the samples.

  2. Collect index statistics and run feature calculations on click data to generate click features.

  3. Analyze search queries and commodity titles to calculate semantic features.

  4. If transaction behavioral data is available, run feature calculations to generate transaction features, which help rank commodities with stronger transaction performance higher.

  5. Combine sample data, behavior features, semantic features, transaction features, and labels into training data; run iterative training on the algorithm.

  6. Output a model describing relevance between search queries and categories.

Training without behavioral data

Use this mode when click data is unavailable, not yet uploaded, you do not want to use the behavioral data on clicks for training, or the data does not meet the training thresholds. Only the category ID and commodity title fields are required.

Without behavioral data, no labels exist for the sample data. The model instead calculates semantic relevance between search query text and commodity titles, using that as the category relevance score.

A model trained with behavioral data produces more accurate predictions because it captures more dimensions of relevance. Both modes require parameter tuning and validation across data from different scenarios.

Prerequisites

Before training a model, ensure you have:

  • A data source that stores commodity data

  • An application to associate with the model

  • Category and commodity data, historical search entries, and behavioral data of the application

  • The following fields specified in the application:

FieldRequiredPurpose
Category IDYesIdentifies the category for each commodity
Commodity titleYesUsed to calculate semantic relevance
Category nameNo (recommended)Displayed on the performance evaluation page for manual review

Including the category name field lets you verify on the performance evaluation page whether predicted category-query relevance matches expectations.

If click data is available and meets the training thresholds, select the additional behavioral data fields when configuring the model.

Get started with category prediction

  1. Create a category prediction model and associate it with an application.

  2. Apply the model to both query analysis and the rough and fine sort stages.

  3. Create a query analysis rule, configure category prediction, and select the model created in step 1.

  4. Make the category prediction model take effect in search requests: use an SDK to call the relevant operations and include the raw_query parameter.

For detailed configuration steps, see Use category prediction.

What's next

After the model is trained, export the prediction results and review them on the performance evaluation page. Confirm that the predicted category-query relevance meets your expectations.