Sub topic 8
Creating a search index
This chapter assumes you can administer Salesforce objects and permission sets, know what a Knowledge article is, and have Knowledge content already available in Data Cloud as a data model object (DMO). The previous chapter covered chunking and embeddings. Here you apply them by building the search index that retrievers query.
What a search index does
A search index is a Data Cloud structure that stores chunks of your content together with their vector embeddings and keyword data. A retriever cannot search raw articles. It can only search an index. If the index is wrong or stale, every grounded answer built on it is wrong or stale too.
Choose a search type
Data Cloud offers three search types for an index.
| Search type | How it matches | Best for |
|---|---|---|
| Vector | Meaning, using embeddings | Natural-language questions with varied wording |
| Keyword | Exact terms | Product codes, error numbers, names |
| Hybrid | Both, with results combined | Most Knowledge use cases |
Hybrid is a sensible default for Knowledge. Customers phrase questions loosely, but articles also contain exact terms such as plan names and error codes.
Create the index
The steps below follow the Data Cloud Setup UI. Labels can vary slightly between releases.
- Open Data Cloud and go to Search Indexes, then choose New.
- Pick the source data model object. For Knowledge, this is the DMO that holds your article content.
- Choose the search type, normally Hybrid.
- Select the fields to index. Include the long-text body field that holds the answer content. Add the title as well.
- Configure chunking. Choose passage extraction, then set the chunk size and overlap, or accept the defaults first.
- Pick an embedding model. Keep the default unless you have a language or domain reason to change it.
- Add any fields you will want later as filters or returned fields, such as language or publish status.
- Save and wait for the build.
Check which content should be indexed
Before you blame the index for a missing answer, confirm the article is published. This SOQL query lists the latest English articles that are online.
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20If an article appears here but not in search results, the problem is in ingestion or the index. If it does not appear, the article was never published.
Common errors
- Indexing the wrong fields. If you skip the body field, the index holds only titles and answers will be thin.
- Missing filter fields. You can only filter on fields you included in the index. Adding one later means rebuilding.
- Expecting instant updates. The index builds and refreshes on a schedule after ingestion. A newly published article may not be searchable right away.
- Changing chunking casually. Chunk and embedding settings changes trigger a rebuild, and results shift. Change one setting at a time and retest.
Exercise
A new article about a return policy is published and visible in the Knowledge__kav query, but a test question about it returns nothing. Name two index-related causes to check.
Show answer
First, the index may not have refreshed since ingestion, so the article's chunks are not in it yet. Second, the body field may not have been included in the indexed fields, so the policy text was never chunked or embedded. Also check that ingestion brought the article into the DMO.