Table of contents :

Words vs Proximity: How Algolia Understands Queries

100-days-of-algolia-027

Table of contents :

For WooCommerce stores, a shopper’s query is rarely an exact product title. A search such as waterproof trail shoes may match product names, categories, attributes, descriptions, and synonyms. Algolia’s ranking system evaluates both how many query words a record matches and how close those words appear to one another. These concepts are related, but they solve different problems.

What Algolia means by “words”

The words ranking criterion rewards records that match more of the words in the query. If a shopper searches for waterproof trail shoes, a product matching all three terms generally has an advantage over one matching only shoes.

This is a relevance signal, not a simple exact-string comparison. Algolia tokenizes the query and searches for matching terms across the configured searchableAttributes. The result can match words in a product name, SKU, brand, category, or another searchable field, depending on the index configuration.

For example, consider these indexed products:

  • Waterproof Trail Running Shoes
  • Trail Shoes
  • Waterproof Hiking Boots

For the query waterproof trail shoes, the first product matches all three words. The second matches two, while the third matches two different words. The words criterion helps Algolia favor records with broader query coverage before later ranking criteria break ties.

What proximity measures

The proximity criterion evaluates the distance between matched query words in a record. Words appearing close together usually indicate a more meaningful match than the same words scattered across a long description.

Suppose two products both match organic cotton shirt:

  • Organic Cotton Shirt contains the terms together in the product name.
  • Organic kitchen range with accessories; cotton fabric details; shirt care instructions contains the same terms, but far apart.

Both records may receive similar credit for matching the words, but the first is typically favored by proximity because the terms form a compact phrase.

Proximity does not mean that Algolia requires the words to be adjacent or in the exact order entered by the shopper. It is a ranking signal that helps distinguish a concentrated match from a scattered one. If your business requires strict phrase behavior, configure and test Algolia’s advanced query syntax rather than relying on proximity alone.

How words and proximity work together

Words and proximity answer different questions:

  • Words: How many of the query’s terms does this record match?
  • Proximity: How close are the matched terms within the record?

A record matching every query word can outrank a record with a very close match for only one word. Conversely, when records match the same number of words, proximity can help place the more coherent product title or description first.

The exact outcome depends on the index’s ranking configuration, searchable attributes, custom ranking, filters, typo tolerance, synonyms, and other search parameters. Agencies should inspect representative results instead of assuming that one ranking criterion operates in isolation.

Why this matters for WooCommerce product data

WooCommerce data often spreads product meaning across several fields. A product name might contain the model, while attributes contain size, material, or color. Categories and descriptions may provide additional context. This can produce useful recall, but it can also create distant matches that are less useful to shoppers.

For example, a query such as black leather boots may match:

  • A product titled Black Leather Chelsea Boots.
  • A product titled Leather Boots with a black color attribute.
  • A long description that mentions black accessories, leather care, and unrelated boots.

Before changing ranking, review whether the important product vocabulary is being indexed in the right attributes. A clean product name and normalized facet values often improve relevance more reliably than adding custom ranking rules.

Practical configuration checks

Review searchable attribute order

Attribute ranking determines which fields are considered more important when other ranking signals are comparable. Put high-value fields, such as product name, brand, and model, ahead of long descriptions or generated content when that reflects the store’s merchandising strategy.

searchableAttributes: [
  'name',
  'brand',
  'sku',
  'categories',
  'description'
]

The exact attribute names depend on the records sent to Algolia. Do not assume that WooCommerce field names are automatically available in the index; verify the transformed record produced by the integration.

Check the ranking order

Algolia ranking is evaluated through a configured ranking formula. In a standard setup, criteria such as typo handling, word matching, filters, proximity, attribute relevance, exactness, and custom ranking contribute to the final order. The placement of these criteria matters. Moving custom business metrics too early can cause products with better sales or margin data to outrank products that are more relevant to the query.

Use the Algolia dashboard or API configuration to review the index’s ranking formula. If you change it, test queries that include:

  • All words present in the product name.
  • Words split between the name and attributes.
  • Words appearing only in a long description.
  • Different word orders and singular or plural forms.
  • Queries containing a brand, model, size, or color.

Use synonyms carefully

Synonyms can increase word coverage, but they can also make proximity results less intuitive. A synonym that maps one shopper term to several product terms may produce matches that are semantically valid but not visually adjacent in the record.

For example, mapping sneakers and trainers can improve recall across regional vocabulary. Test whether the resulting products still appear in a useful order for key commercial queries. Maintain separate synonym rules for genuinely equivalent terms rather than using broad replacement rules to compensate for poor product data.

Distinguish ranking from filtering

Color, size, stock status, price range, and category restrictions should normally be modeled as facets or filters, not left entirely to textual relevance. A query for red running shoes can use text relevance for “running shoes” and a color facet for an explicitly selected red filter.

This separation gives shoppers predictable behavior: the filter removes products that do not satisfy the selected constraint, while words and proximity rank the remaining products.

Testing words versus proximity

Create a relevance test set from real WooCommerce search analytics. For each query, record the products that merchandising or customer-support teams consider useful. Include both short and long queries, because proximity has more opportunity to differentiate results when a query contains several words.

A useful test matrix includes:

  1. Run the query against the production-style index.
  2. Record whether the top results match all query words.
  3. Compare products where terms are adjacent with products where terms are separated across fields or descriptions.
  4. Check whether filters and attribute ranking produce the expected business behavior.
  5. Review changes after every ranking, synonym, or data-transformation update.

When debugging a surprising result, request ranking information where appropriate and inspect the matched attributes, word coverage, exactness, and proximity-related details exposed by Algolia’s response. This helps determine whether the issue is missing data, an unexpected synonym, attribute priority, or the ranking formula itself.

Implementation example

A frontend search request can remain simple while the index configuration handles the relevance model:

const results = await index.search('waterproof trail shoes', {
  hitsPerPage: 24,
  facets: ['brand', 'categories', 'color', 'size'],
  filters: 'inventory_available = true'
});

The query does not need to manually sort products by string distance. Algolia evaluates its configured ranking criteria, while the application supplies optional filters and presentation settings. Keep business rules that remove products, such as stock or market eligibility, in filters whenever they are true constraints.

Guidance for WooCommerce agencies

When tuning a client’s search experience, start with index quality and query evidence. Confirm that product names, brands, categories, variations, and attributes are normalized and available in the intended searchable fields. Then evaluate words coverage, proximity behavior, filters, synonyms, and custom ranking in that order.

Do not add a custom ranking attribute simply because a result with a high sales count appeared first. First determine whether the result matched fewer words, relied on a synonym, matched a low-priority attribute, or was affected by missing product data. A ranking change that fixes one query can easily damage the broader catalog if it obscures word coverage or proximity.

The most dependable configuration is one in which a product that satisfies the shopper’s terms is easy to find, a product with those terms expressed together receives an appropriate advantage, and explicit constraints such as stock, category, and selected facets behave predictably.

Trending posts
You might also like