SemanticSearch[index,query]
finds the items similar to query inside index.
SemanticSearch[index,query->f]
filters the results using the function f.
SemanticSearch[index,query,prop]
returns the specified property prop.


SemanticSearch
SemanticSearch[index,query]
finds the items similar to query inside index.
SemanticSearch[index,query->f]
filters the results using the function f.
SemanticSearch[index,query,prop]
returns the specified property prop.
Details and Options



- SemanticSearch performs a search on the semantic index using a query to find and retrieve similar text items.
- Valid index specifications are:
-
"name" a string matching a named semantic search index SemanticSearchIndex[…] a valid SemanticSearchIndex object - The input to the function f is the same annotation specified when the index was created.
- Possible values for prop include:
-
"Distance" distance between the encoded query and item "Item" item that matches "query" (default) "ItemEmbedding" encoded item "Label" item label "Query" specified query "QueryEmbedding" encoded query "Tags" item tags "Tags""tag" a single item tag "Tags"{"tag1",…} multiple item tags {prop1,…} a list of properties All an Association with all the properties - The following options can be given:
-
MaxItems 10 how many items are returned ProgressReporting $ProgressReporting whether to display progress information RerankingMethod Automatic how to reorder items once retrieved - Values for the RerankingMethod include:
-
Automatic default reranking None no reranking Tiny, Small, Medium, Large predefined model sizes "string" a generic SemanticRanking model {"string",size} a specific-sized SemanticRanking model f a custom reranking function <|opt1 val1,…|> detailed options specifying reranking parameters - A custom ranker f must operate on the reference string and a list of strings to produce a vector of the same length.
- Detailed options for the RerankingMethod include:
-
"Function" SemanticRanking function ranking the candidate items "MaxItemMultiplier" 2 multiple of MaxItems provided as candidates "MinItems" 10 minimum number of candidate items "Query" Automatic query string used for ranking "Target" "Item" which property prop the function operates on - With "Query"Automatic, the input query is used for the reranking as well.
- When reranking with "MinItems"min, "MaxItemMultiplier"k and MaxItemsmax, the initial number of candidate items is Max[min,k*max].
Examples
open all close allBasic Examples (1)
Create a SemanticSearchIndex:
Scope (3)
Create a SemanticSearchIndex with a single source:
Find index items closest to a given query:
Get a list of available result properties:
Extract a specific item property:
Retrieve all available properties:
Define an index with labeled sources:
The label is automatically returned when searching:
Return the item and the label:
Filter to only search items with a specific label:
Define an index with tagged sources:
The tags are automatically returned when searching:
Options (5)
RerankingMethod (4)
Search with automatic reranking:
Disabling reranking can make the results faster but may degrade results:
Specify a custom reranking method as a function of the items:
Specify the reranker as a function of the items and the query:
Reranking defaults to a minimum of 10 candidate items retrieved from the database, then returns the requested number of MaxItems:
Disabling reranking will give the first result from the initial search:
Reduce the minimum number of candidate items provided to the reranker:
The number of candidates is calculated by taking the larger of "MinItems" and the product of the "MaxItemMultiplier" method option and the specified number of MaxItems:
Create an index with tags corresponding to the frequency of words in the text:
Default sorting gives close matches, but the first match may be obscure or only mentioned a few times in the text:
Rerank based on the most prevalent words:
Use a custom question when reranking to further refine the results:
Applications (4)
Search Shakespeare's sonnets using partial quotes. Use a manual splitting of the text to group each sonnet together with its number:
Then label each sonnet with its number:
Create a index using the labeled sonnets:
Retrieve sonnets and their number using a partial quote:
Look for a vaguely remembered sonnet:
Retrieve the index of the Wolfram Function Repository:
Search for custom functions that can generate a graphic of the solar system:
Search for a specific example in the given function:
Run the example function from the given item:
Create an index from a set of books:
Find some examples on a topic of interest:
Use LLMSynthesize to give a summary contrasting the differences:
Create an index containing German and English text:
The embeddings of the same meanings are similar across languages. Search in English for information in the German source:
Properties & Relations (3)
When performing a search, the distance function specified in CreateSemanticSearchIndex is used:
The distance function setting can be retrieved from the VectorDatabaseObject backing the index:
Items will always share the tag of their source:
To get list of source tags, use unique tags and DeleteDuplicates:
SemanticSearch automatically reranks the results using SemanticRanking:
This is the equivalent of retrieving 10 results without reranking (the default "MinItems" for reranking):
Then taking the first five results of the results after using SemanticRanking:
Related Guides
Text
Wolfram Research (2024), SemanticSearch, Wolfram Language function, https://reference.wolfram.com/language/ref/SemanticSearch.html (updated 2025).
CMS
Wolfram Language. 2024. "SemanticSearch." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/SemanticSearch.html.
APA
Wolfram Language. (2024). SemanticSearch. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SemanticSearch.html
BibTeX
@misc{reference.wolfram_2025_semanticsearch, author="Wolfram Research", title="{SemanticSearch}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/SemanticSearch.html}", note=[Accessed: 13-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_semanticsearch, organization={Wolfram Research}, title={SemanticSearch}, year={2025}, url={https://reference.wolfram.com/language/ref/SemanticSearch.html}, note=[Accessed: 13-August-2025]}