Sub topic 8
Creating a search index
A search index is the Data Cloud structure that stores chunks of your content and their vector embeddings, so a retriever can find relevant passages quickly. This chapter covers how to create one over Knowledge content, which options matter, and which errors are common.
This chapter assumes you already know the following:
- Basic Salesforce administration, including objects, fields, and permission sets.
- How Knowledge articles are published and what the
Knowledge__kavobject holds. - That your Knowledge content already reaches Data Cloud through a data stream and a data model object (DMO). The previous chapters covered this.
- What chunking and vector embeddings are, at the level of "text becomes passages, and passages become numbers that capture meaning".
What a search index does
A search index sits between your ingested content and the retriever. You point it at a DMO, choose which fields to index, and choose how to chunk and embed the text. Data Cloud then builds and maintains the index. The retriever you create in the next chapter queries this index, not the raw DMO.
The index creates two kinds of data from each record:
- Chunks. Pieces of the source text, each linked back to the parent record.
- Vectors. One embedding per chunk, produced by an embedding model.
At query time, Data Cloud embeds the question, compares it with the stored vectors, and returns the closest chunks. In hybrid search, it also scores keyword matches and combines both rankings.
Before you create the index
Check these items first. Most failed index builds trace back to one of them.
- Confirm the articles exist and are published. Run a query like the one below in Developer Console or Workbench. If it returns nothing, nothing can be ingested.
- Confirm the data stream has run successfully and the DMO contains rows. An empty DMO produces an empty index with no error.
- Confirm you have the Data Cloud permissions needed to create search indexes. Use a Data Cloud admin or equivalent permission set. Names vary by release, so check Setup if the option is missing.
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20This query lists the most recently published English article versions. You can compare it with the rows in the DMO to check that the content you expect is available.
Creating the index
The exact screens change between releases, but the decisions are the same. In Data Cloud, open Search Indexes and choose to create a new one.
- Choose the source. Select the DMO that holds your Knowledge content, for example the Knowledge article version DMO or the unstructured data model object created by your ingestion method.
- Choose the search type. Pick vector search, or hybrid search if you want keyword matching combined with semantic matching.
- Choose the fields to index. Select the text fields that contain the answer content, such as the title, summary, and body.
- Configure chunking. Accept the default passage-extraction strategy, or adjust chunk size and overlap if the options are shown.
- Choose the embedding model. Pick one of the available models.
- Choose related fields to carry along. These are fields, such as the URL name or language, that the retriever can later return or filter on.
- Save and build. The index is created in a processing state and becomes ready when the build finishes.
Vector search or hybrid search
| Aspect | Vector search | Hybrid search |
|---|---|---|
| Matching | Semantic similarity between embeddings | Semantic similarity plus keyword matching |
| Strength | Paraphrased questions, natural language | Exact terms such as product codes, error numbers, and names |
| Weakness | Can miss exact identifiers | Slightly more setup and tuning |
| Typical use | Conversational help content | Content that mixes prose with part numbers or acronyms |
If your articles mention identifiers that customers type exactly, hybrid search is usually the safer choice. Pure vector search can rank a semantically similar but wrong article above the exact match.
Choosing fields
Field choice affects both answer quality and the size of the index.
- Index the fields that contain answer text. The title is short but carries a strong signal. The body carries the detail.
- Do not index fields that are only labels, such as status flags or internal IDs. They add noise.
- Keep fields you want to filter on as related or filterable fields, not as indexed text. Language, data category, and channel visibility are typical examples.
- Include a field that lets the agent cite its source, for example the title or the URL name.
A common mistake is indexing only the summary field because it is short and clean. If the real answer lives in the body, retrieval will find the right article but the returned chunk will not contain the answer.
Chunking choices
Chunking splits long text into passages before embedding. Two properties matter.
- Chunk size. Smaller chunks give precise matches but may lose context. Larger chunks keep context but dilute the match, because one vector represents more topics.
- Overlap. Overlapping chunks reduce the risk that an answer is split across a boundary.
For typical help articles with short headed sections, the defaults are a reasonable start. Revisit them only after testing shows a problem, for instance chunks that end in the middle of a procedure. Changing chunking later means rebuilding the index.
Build status and freshness
An index is not instantly current. After the first build, Data Cloud updates it as the underlying DMO changes, but there is a delay. Typical failure patterns:
| Symptom | Likely cause | What to check |
|---|---|---|
| Index stays in a processing or failed state | Source DMO is empty or a field mapping is broken | Row count in the DMO and the data stream's last run |
| Index is ready but returns nothing | Wrong fields indexed, or filters exclude everything | Indexed field list and any filters on the retriever |
| New article is not found | Article was not yet published, or the stream has not refreshed | `PublishStatus`, the data stream schedule, and the index's last update |
| Retired article still appears | Source row is still in the DMO | Whether archived or deleted articles are removed on the next stream refresh |
The data stream schedule limits freshness. If the stream refreshes daily, the index cannot be more current than the last refresh, however quickly it rebuilds.
Common errors
- Indexing the wrong DMO. Several DMOs may look similar. Open the DMO and confirm it contains article text before you select it.
- Selecting too many multilingual rows. If the DMO contains several languages and you only support one, include a language field so the retriever can filter it later.
- Treating the index as the retriever. The index stores data. The retriever defines how it is queried, including filters and the number of results. You still need to create one.
- Rebuilding without a plan. Each configuration change that affects chunks or vectors triggers a rebuild. Change one thing at a time so you can tell what improved results.
Verifying the index
Before you build a retriever, check the index directly.
- Open the index and confirm its status is ready.
- Look at the index's chunk count. A count of zero, or one far lower than your article count, signals an ingestion problem.
- Where the interface offers a data exploration or query view, sample a few chunks. Confirm the text is readable, not truncated, and linked to the correct article.
Once these checks pass, you are ready to create and test a retriever over the index.
Exercise
Your hybrid search index is ready, but a customer who types an exact error code such as "ERR-4471" gets an unrelated article. The correct article contains that code only in its body. Which index configuration problem is the most likely cause, and what do you change?
Show answer
The most likely cause is that the body field was not included in the indexed fields, so the code never appears in any indexed chunk. Add the body field to the indexed fields and rebuild the index. If the body is already indexed, check that the index uses hybrid rather than vector-only search, since only keyword matching reliably finds exact identifiers.
Exercise
An article was unpublished in Salesforce Knowledge an hour ago, but the agent still quotes it. Name two things you check and one reason this can happen even when everything is configured correctly.
Show answer
Check whether the row for the article is still present in the Data Cloud DMO, and check the data stream's last successful refresh and the index's last update time. It can happen correctly because the index only reflects Data Cloud, which updates on the data stream schedule, so there is a delay between unpublishing and removal from the index.