Sub topic 7
How content becomes searchable chunks and vectors
This chapter explains what happens to a Knowledge article after it lands in Data Cloud and before a retriever can return it. You will see how long text is split into chunks, how each chunk becomes a vector, and how those choices affect the answers an agent gives.
Prerequisites
This chapter assumes you already know the following:
- Salesforce Knowledge articles and the difference between draft and published versions.
- The idea of a large language model (LLM) and why ungrounded answers are risky.
- That Knowledge content reaches Data Cloud through a data stream and is stored in data model objects (DMOs).
You do not need any machine learning background. Where a term comes from that field, it is defined here.
Why the pipeline splits and encodes content
A retriever must return a small piece of text that answers the question. It cannot hand a whole 6,000-word article to a prompt, for two reasons:
- A prompt has a limited size. Large inputs crowd out instructions and other context.
- A long article covers many topics. Its overall meaning is blurry, so it matches many questions weakly and none strongly.
The pipeline fixes this in two steps. First it splits each article into chunks, which are short passages of text. Then it turns each chunk into a vector embedding, which is a list of numbers that represents the meaning of the text. Chunks with similar meaning get vectors that sit close together. A search can then compare the question's vector with chunk vectors and return the nearest ones.
In Data Cloud, you do not run these steps by hand. You configure them when you create a search index, and Data Cloud runs them each time the source data changes. The next chapter covers the index screen. This chapter covers what the settings mean.
Chunking
What a chunk is
A chunk is a contiguous piece of a text field, such as part of an article body. Data Cloud stores each chunk as a row in a generated chunk DMO. Each row keeps a reference back to its source record, so the retriever can return the article title, URL name, or other fields alongside the passage.
Chunking strategies
When you configure a search index, you choose how text is split. The options you will see depend on your release, so check the current setup screen. The common ideas are:
| Approach | How it splits | Good for | Risk |
|---|---|---|---|
| Passage extraction by size | Cuts text into passages near a target length, often with overlap | Long, unstructured prose | A cut can fall mid-explanation |
| Section or structure based | Follows headings and paragraphs | Well-formatted articles | Very long sections stay long |
| Advanced or custom options | Adds settings such as a token limit or a prefix field | Content with special structure | More settings to tune and test |
Treat the table as a map of concepts, not a list of exact menu names.
Chunk size and overlap
Two settings matter most:
- Chunk size is usually measured in tokens. A token is a small unit of text, roughly three quarters of an English word. Small chunks give precise matches but can lose context. Large chunks keep context but dilute meaning and use more of the prompt.
- Overlap repeats the end of one chunk at the start of the next. It reduces the chance that an answer is split across a boundary.
A practical starting point is a few hundred tokens per chunk with modest overlap. Then test with real questions and adjust. There is no universal best value.
A worked example
Suppose an article titled "Return a damaged item" has this body:
- A paragraph on eligibility (30 days from delivery).
- A paragraph on how to start a return.
- A paragraph on refunds (5 to 7 business days).
With section-based chunking, you might get three chunks, one per paragraph. The question "How long do refunds take?" matches the third chunk strongly, and only that passage reaches the prompt.
If the chunks were far larger, one chunk would hold all three paragraphs. The refund sentence would be a small part of a bigger text, and its match score would drop.
Embeddings
What an embedding model does
An embedding model is a neural network that reads text and outputs a fixed-length vector, often hundreds or thousands of numbers. You never read these numbers. You only compare them. Closeness is measured with a function such as cosine similarity, which scores how similar the direction of two vectors is. A score near 1 means very similar meaning. A score near 0 means unrelated.
Because the model encodes meaning, "How do I get my money back?" can match a chunk that says "Refunds are issued within 5 to 7 business days" even though they share almost no words. This is the main advantage over plain keyword search.
The same model must embed both sides
The question and the chunks must be embedded with the same model. Vectors from different models are not comparable. When you create a search index you pick the embedding model once, and Data Cloud uses it for both the chunks and the incoming queries. If you later change the model, the index must be rebuilt so every chunk gets a new vector.
Language
Embedding models differ in language support. If your articles are in several languages, check that the model you select supports them. A Knowledge query that filters on Language = 'en_US' can confirm what you have. Use the SOQL query below to list the published English versions that should be indexed.
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20Vector search, keyword search, and hybrid search
Vectors find meaning, but they can be weak on exact strings such as product codes, error numbers, or names. Keyword search is the reverse. A hybrid search runs both and combines the results.
| Search type | Strength | Weakness |
|---|---|---|
| Vector | Handles paraphrases and natural questions | Can miss exact identifiers |
| Keyword | Finds exact terms and codes | Misses different wording |
| Hybrid | Covers both | Needs more tuning and test cases |
If your content contains part numbers, error codes, or policy IDs, hybrid search is usually the safer choice.
What gets chunked and embedded
Not every field needs to be indexed. You choose which text fields to chunk and which to keep as plain returned or filterable fields.
- Chunk and embed: article body fields and the title when it adds meaning.
- Keep as metadata:
UrlName, language, publish date, and data categories. These are used for filters and for the fields a retriever returns.
Indexing fewer, cleaner fields gives better matches than indexing everything. Boilerplate such as repeated disclaimers adds noise and produces chunks that match many unrelated questions.
Freshness
Chunks and vectors are derived data. They do not update the instant an article changes. The sequence is:
- A new article version is published.
- The data stream refreshes the DMO on its schedule.
- The search index processes the changed records, creating new chunks and vectors and removing old ones.
A delay at any step means a retriever can return an old passage. When a customer sees outdated policy text, check each step in order before blaming the model. The troubleshooting chapter covers this in detail.
Common errors
- Chunks too large. Symptom: the retriever returns the right article, but the passage is long and the agent's answer drifts. Reduce the chunk size.
- Chunks too small. Symptom: passages lack context, such as a sentence that says "This applies within 30 days" with no subject. Increase the size or add overlap.
- Wrong field indexed. Symptom: results look unrelated. Confirm that the field you chunked contains the article text.
- Model changed without a rebuild. Symptom: poor relevance after a settings change. Rebuild the index.
- Exact codes not found. Symptom: a question with a part number returns nothing useful. Switch to hybrid search.
- Draft content expected. Only published articles are ingested in a typical setup. Verify the publish status with the SOQL query above.
Quick checklist
- Confirm the articles are published and in the language you expect.
- Choose which text fields to chunk and which to keep as metadata.
- Start with moderate chunk sizes and some overlap.
- Use hybrid search if exact identifiers matter.
- Test with real customer questions and read the returned chunks, not only the final answer.
Exercise
A customer asks "What is error E-4012?" and the retriever returns chunks about general login problems, even though one article mentions E-4012 in its body. The index uses vector search only. What is the most likely cause, and what would you change first?
Show answer
Vector search matches meaning and can miss exact identifiers like E-4012, so the chunk containing the code may rank below more general passages. Switch the index to hybrid search so keyword matching on the exact code contributes to ranking. Then retest, and if the problem remains, check that the body field is chunked and the article is published and refreshed.
Exercise
You change the embedding model on an existing search index and results become worse. Why can't old chunk vectors be mixed with the new model's query vectors, and what must you do?
Show answer
Vectors from different embedding models are not comparable, because each model has its own numeric space. Query vectors from the new model cannot be fairly matched against chunk vectors made by the old model. You must rebuild the index so every chunk is re-embedded with the new model.