Table of contents :

Combining “Under €100” With Semantic Search

100-days-of-weaviate-033

Table of contents :

Price constraints and semantic intent solve different parts of a WooCommerce search request. In a query such as “comfortable waterproof walking shoes under €100,” semantic search should identify the relevant products, while a structured filter should enforce the budget.

Do not rely on the vector representation to interpret the price limit. Embeddings capture meaning and product relationships, but they are not a reliable mechanism for enforcing numeric conditions. Store price as a numeric property in Weaviate and apply the constraint as a filter during the search.

Model the price as structured data

Every product imported from WooCommerce should have a normalized numeric price field. For example:

{ "product_id": 1842, "name": "Waterproof Trail Shoe", "description": "Lightweight walking shoe with a breathable membrane", "price_eur": 89.95, "currency": "EUR", "stock_status": "instock", "categories": ["shoes", "walking"] }

Use a numeric field such as price_eur, rather than indexing a formatted string such as €89.95. A numeric property allows Weaviate to apply comparisons such as LessThan and LessThanEqual.

For agencies supporting multiple currencies, decide where normalization occurs. A common approach is to convert prices to a reporting currency during the WooCommerce-to-Weaviate synchronization process and retain the original currency and display price separately. The conversion rate and tax basis should be defined consistently, especially when the store displays tax-inclusive prices.

Apply a numeric filter to a semantic query

The following GraphQL query searches semantically for suitable walking shoes and restricts the result set to products below €100:

query { Get { Product( nearText: { concepts: ["comfortable waterproof walking shoes"] } where: { path: ["price_eur"] operator: LessThan valueNumber: 100 } limit: 12 ) { product_id name description price_eur _additional { distance } } } }

The nearText clause provides the semantic part of the request. The where clause provides the deterministic business rule. Weaviate evaluates the filter against the indexed property, so a product priced at €100 is excluded by LessThan. If “under €100” should include exactly €100, use LessThanEqual instead.

Use hybrid search when product terminology matters

Semantic search is useful when customers describe an outcome or use case, such as “shoes for long wet walks.” Keyword relevance is still valuable for exact model names, technical standards, and product terms. Hybrid search combines both signals while retaining the price filter:

query { Get { Product( hybrid: { query: "comfortable waterproof walking shoes" alpha: 0.7 } where: { path: ["price_eur"] operator: LessThan valueNumber: 100 } limit: 12 ) { product_id name price_eur _additional { score } } } }

The appropriate alpha depends on the catalog. A higher value gives more weight to vector similarity; a lower value gives more weight to keyword matching. Agencies should test this against real WooCommerce search logs rather than choosing one value globally.

Parse the budget before searching

The application layer should separate the customer’s natural-language request into a semantic query and a structured constraint. For example:

  • Semantic text: “comfortable waterproof walking shoes”
  • Price operator: LessThan
  • Price value: 100
  • Currency: EUR

This parsing can be implemented with deterministic patterns for common expressions such as “under,” “below,” and “less than.” If a query contains an ambiguous phrase such as “around €100,” map it to an explicit product decision, such as a range from €80 to €120, or ask the shopper to clarify. The important point is that the resulting numeric value must be passed to the Weaviate filter, not left only in the text sent to the vectorizer.

A simplified application-side representation might look like this:

const searchRequest = { semanticQuery: 'comfortable waterproof walking shoes', price: { operator: 'LessThan', value: 100, currency: 'EUR' } };

The server can then construct the Weaviate query from validated fields. Do not accept arbitrary property paths or operators directly from the browser. Map approved request values to a fixed query builder so shoppers cannot use the search endpoint to access unrelated properties.

Handle WooCommerce price semantics explicitly

WooCommerce stores several price concepts, including regular price, sale price, and the current displayed price. Decide which one the budget filter represents. In most storefronts, the customer expects “under €100” to use the current selling price, so the synchronization job should populate price_eur from the effective product price.

For variable products, index the variation-level price range or create separate searchable records for variations. If a parent product has a range from €79 to €129, filtering only the parent’s maximum price would incorrectly hide a product with an eligible €79 variation. A practical model is:

{ "product_id": 1842, "variation_id": 1851, "parent_id": 1842, "name": "Waterproof Trail Shoe - Size 42", "price_eur": 89.95, "attributes": { "size": "42", "color": "black" } }

If the storefront displays parent products, the application can group matching variations by parent_id after retrieval. It should preserve the lowest qualifying price and ensure that the selected variation is actually purchasable.

Keep filters synchronized with catalog changes

Price is more volatile than product descriptions. A sale, scheduled promotion, tax change, or currency update can make a previously indexed budget result incorrect. WooCommerce webhooks or an event-driven synchronization process should update the numeric property whenever the effective price changes.

After changing the schema or data type, verify the imported objects directly. A string value such as "89.95" is not equivalent to the numeric value 89.95 for comparison filtering. Include checks for missing prices, negative values, unexpected currencies, and stale products during the synchronization process.

Test relevance and constraint correctness separately

Use two groups of tests for this search pattern:

  1. Constraint tests: every returned product satisfies the price operator, currency, stock, visibility, and tax assumptions.
  2. Relevance tests: the returned products match the requested use case, materials, category, and other semantic requirements.

For example, a relevance test can use the query “quiet office keyboard under €100,” while a constraint test verifies that no result has price_eur >= 100. Also test boundary values such as €99.99, €100.00, missing prices, sale prices, and products with multiple variations.

In a WooCommerce integration, the final request path should therefore be: normalize the catalog price, parse the shopper’s budget, construct a validated numeric filter, run semantic or hybrid retrieval, apply any additional visibility and stock filters, and format the returned price using the storefront’s currency rules.

Trending posts
You might also like