Retrieval-augmented generation (RAG) does not usually send an entire product catalog, documentation site, or support archive to a language model. Instead, it retrieves a small set of relevant passages and adds them to the model’s prompt. Document chunking is the process of dividing source content into those retrievable passages.
For WooCommerce agencies, chunking affects much more than search performance. It influences whether an AI assistant can find the correct product policy, whether a support response includes the right shipping exception, and whether a store’s product recommendations are grounded in the right attributes. Poorly sized or poorly structured chunks can make an otherwise capable RAG implementation inaccurate, expensive, and difficult to maintain.
What document chunking means
A document chunk is a section of source content that is stored and retrieved as an independent unit. During indexing, a document is divided into chunks, each chunk is converted into an embedding, and the embedding is stored in a vector index alongside metadata and usually the original text.
When a customer asks a question, the question is also converted into an embedding. The retrieval system compares that query representation with the indexed chunk representations and returns the closest matches. The selected chunks are then included in the prompt sent to the language model.
A chunk might contain:
- A heading and the paragraphs below it from a knowledge-base article.
- A WooCommerce product description and a group of related attributes.
- A shipping policy section describing delivery zones and exclusions.
- A support ticket conversation containing the resolution to a specific issue.
- A product variation table or a structured FAQ entry.
Chunking is therefore an information-design decision. It determines what information can be retrieved together and what context is separated into different search results.
Why RAG needs chunks
Language-model context is limited
Even models with large context windows have practical limits. Sending an entire WooCommerce catalog, a complete returns policy, or every support article for every question increases prompt size, latency, and cost. It also makes it harder for the model to identify the relevant facts.
RAG narrows the context to the passages that are likely to answer the question. Chunking provides the granularity required for that selective retrieval.
Retrieval works on indexed units
A vector search system does not retrieve an abstract topic from a document. It retrieves the indexed records that contain the closest semantic matches. If a 20-page policy is stored as one vector, a query about international returns may retrieve the whole policy, but the representation may be too broad to distinguish that section from unrelated information about domestic returns or warranty claims.
When the policy is divided into meaningful sections, the international returns section can have its own representation and rank more accurately for the relevant query.
Chunks provide evidence for grounded answers
A RAG response is only as well-grounded as the content supplied to the model. A focused chunk gives the model a smaller evidence set and makes it easier to cite or link to the original page. If a chunk combines unrelated products, policies, or instructions, the model may blend details that were never intended to appear together.
Common chunking strategies
Fixed-size chunking
Fixed-size chunking divides text after a specified number of characters, words, or tokens. It is easy to implement and provides predictable index sizes, but it can split a sentence, list, table, or product specification at an inconvenient point.
For example, splitting a returns policy every 500 tokens could separate the eligibility rules from the exclusions that qualify them. The retrieved passage may then contain an apparently complete answer that is actually missing an important condition.
Recursive or separator-based chunking
Recursive chunking attempts to split content at progressively smaller structural boundaries. It may try headings first, then paragraphs, sentences, and finally token or character limits. This generally preserves more natural passages than a fixed character count.
This approach is useful for WordPress content because posts and pages already contain structural elements such as headings, paragraphs, lists, and block boundaries.
Heading-based chunking
Heading-based chunking creates a chunk from a heading and its associated content. A page section such as International Shipping Restrictions can remain together with the explanatory paragraphs and bullet points beneath it.
Include the parent heading path when indexing nested sections. A chunk labelled Shipping > International Shipping > Restricted Items carries more context than the paragraph text alone.
Semantic chunking
Semantic chunking groups sentences or paragraphs that discuss the same subject. It can be useful when a document has weak or inconsistent formatting, but it is more computationally expensive and can produce inconsistent chunk sizes.
Structured-field chunking
Product and order data often should not be chunked as ordinary prose. A product chunk can be assembled from specific fields such as the product name, short description, category, attributes, availability, dimensions, and relevant custom fields.
For example:
Product: Alpine Rain Shell
Category: Women's waterproof jackets
Material: Three-layer recycled nylon
Waterproof rating: 20,000 mm
Sizes: XS, S, M, L, XL
Care: Machine wash cold; do not use fabric softener
This format makes related product facts retrievable together and avoids mixing them with unrelated content from the product page, such as promotional banners or navigation text.
Choosing chunk size
There is no universal ideal chunk size. The correct size depends on the content, query patterns, embedding model, prompt budget, and the amount of context required to answer a question.
Chunks that are too small may lose necessary context. A chunk containing only “Not eligible after 30 days” is difficult to interpret without knowing what “not eligible” refers to. Very small chunks can also increase the number of retrieved records needed for one answer.
Chunks that are too large may contain several unrelated subjects. A product-support chunk that includes installation instructions, warranty terms, compatibility notes, and unrelated marketing copy may match many queries weakly instead of one query strongly.
A practical starting point for prose content is a few hundred tokens per chunk, adjusted through retrieval testing. The exact token count should be treated as an experiment rather than a fixed rule. Product records, FAQs, tables, and policy sections may need different limits.
Use overlap carefully
Chunk overlap repeats a small amount of content at the boundary between adjacent chunks. Overlap can prevent a sentence or explanation from being separated from the context needed to understand it.
For example, if a paragraph introduces a refund exception and the next paragraph defines that exception, a modest overlap may allow both chunks to preserve the relationship. However, excessive overlap duplicates text in the vector index and retrieved prompt. It can increase storage, retrieval redundancy, and prompt costs without improving accuracy.
Overlap should support boundary continuity, not compensate for poor document structure. If a heading, table, or list is repeatedly split in the wrong place, improve the structural chunking rule first.
Chunking WooCommerce content
Product pages
Separate product information from site-wide boilerplate. Header navigation, cookie notices, related-product widgets, and repeated calls to action should not become part of every product chunk.
A useful product index record may include:
- The product title and a stable product or variation identifier.
- The product type, category, brand, and taxonomy terms.
- The short description and relevant long-description sections.
- Attributes such as size, color, material, compatibility, and dimensions.
- Price and stock data when the retrieval system is designed to index changing values.
- The canonical product URL and the last modification timestamp.
For variable products, decide whether to create one parent chunk, one chunk per variation, or both. A parent chunk is useful for general product questions. Variation-level chunks are more appropriate when customers ask whether a particular size or configuration is available.
Policies and documentation
Keep the title, section heading, conditions, exceptions, and effective date together where possible. A returns chunk should not contain only the headline rule while leaving the exclusions in another unrelated chunk.
Store metadata such as document type, locale, customer region, product category, and effective date. Metadata filters can prevent a US shipping rule from being retrieved for a customer whose address is in the United Kingdom.
Support content
Support tickets often contain useful answers but also contain personal data, outdated troubleshooting steps, and conversation noise. Before indexing, remove sensitive information, identify the issue and resolution, and preserve product or version metadata.
A support chunk should make the resolution understandable without requiring the model to retrieve every preceding message. For example, index a normalized record containing the error, affected extension version, diagnostic steps, and verified fix.
Metadata is part of chunk quality
Text embeddings are not a replacement for structured filters. Add metadata that can narrow retrieval before or after vector similarity is calculated.
- Source: product, page, post, FAQ, ticket, or documentation.
- Object identifier: WooCommerce product ID, variation ID, post ID, or document ID.
- Taxonomy: category, brand, tag, or store department.
- Locale: language, country, currency, or market.
- Lifecycle: publication status, effective date, and last synchronization time.
- Permissions: whether the content is public, staff-only, or restricted to a customer account.
For example, a query about a discontinued product should not retrieve a current replacement unless the application intentionally allows substitute recommendations. Metadata lets the retrieval layer enforce that distinction.
How WPSOLR fits into the workflow
In a WordPress and WooCommerce implementation using WPSOLR, the indexing configuration should be treated as part of the RAG design. Decide which post types, taxonomies, custom fields, and product data are sent to the search index. Then inspect how the content is represented before relying on it as context for an AI feature.
A practical workflow is:
- Identify the content types the assistant must answer from, such as products, documentation, policies, and FAQs.
- Remove boilerplate and exclude content that should not be searchable or exposed to customers.
- Define field-specific or heading-aware chunk rules rather than applying one rule to every post type.
- Attach stable WordPress and WooCommerce identifiers, URLs, taxonomies, locale, and update timestamps.
- Index a representative sample and inspect the actual chunks returned for real customer questions.
- Adjust chunk boundaries, overlap, filters, and ranking rules based on retrieval results.
- Reindex content after changing the chunking logic and verify that deleted or unpublished content is no longer retrievable.
The exact WPSOLR configuration depends on the search backend and the site’s indexing setup. The important implementation principle is to validate the indexed representation, not just the visible WordPress page. A visually clean page can still produce poor chunks if the extractor includes navigation, repeated widgets, or hidden metadata in the searchable text.
Testing chunking with WooCommerce questions
Evaluate chunks with questions that reflect real usage rather than only checking whether indexing completed successfully. Include questions such as:
- “Can I return a personalized item?”
- “Does this jacket fit over a fleece in size medium?”
- “Which replacement filter works with model A-200?”
- “Do you ship lithium-battery products to Norway?”
- “What should I do when checkout shows an invalid postcode error?”
For each question, inspect the top retrieved chunks and record whether they are relevant, complete, current, and permitted for the requesting user. A useful chunking change should improve retrieval of the necessary evidence without flooding the prompt with duplicate or unrelated content.
Also test boundary cases. Ask about an exception, a product variation, an old policy, a multilingual page, and a document with a table. These cases often reveal that a chunking rule works for ordinary paragraphs but fails for the content customers actually need.
Operational issues agencies should plan for
Content updates
When a product price, stock status, policy, or compatibility statement changes, the corresponding chunks must be updated or removed. Keep source identifiers and timestamps so an indexing job can detect changes and avoid leaving stale records in the vector index.
Access control
Do not assume that a vector index automatically respects WordPress permissions. Private posts, staff documentation, customer-specific data, and order information require explicit filtering and authorization before retrieved text is placed in a prompt.
Multilingual stores
Keep language and market metadata with every chunk. Depending on the embedding and search configuration, it may be useful to index translated content separately and retrieve content in the customer’s language rather than combining multiple languages in one chunk.
Prompt budget
Retrieval quality and prompt size must be considered together. Returning ten large chunks may reduce the chance of missing a fact, but it can also dilute the answer with competing instructions and increase model cost. Measure the minimum number of chunks that reliably provides complete evidence for each class of question.
A practical rule for chunk design
Design each chunk so that a knowledgeable reviewer can understand its subject, source, and scope without reading the entire site. Preserve the heading or product identity, keep related conditions together, exclude repeated boilerplate, attach useful metadata, and test the result against real WooCommerce queries.
When a retrieved chunk is relevant but incomplete, the fix may be a larger structural unit or controlled overlap. When it is broad and noisy, the fix may be smaller sections, better field selection, or metadata filters. When it is accurate but outdated, the fix is indexing and lifecycle management rather than a different language model.