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
    "Source"item source
    "Tags"item tags
    "Tags""tag"a single item tag
    "Tags"{"tag1",}multiple item tags
    {prop1,}a list of properties
    Allan Association with all the properties
  • The following options can be given:
  • MaxItems 10how many items are returned
    ProgressReporting$ProgressReportingwhether to display progress information

Examples

open allclose all

Basic Examples  (1)

Create a SemanticSearchIndex:

Extract the most relevant quote from Alice in Wonderland:

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:

Get multiple properties:

Retrieve all available properties:

Define an index with labeled sources:

The label is automatically returned when searching:

Return the item instead:

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:

Return a specific tag value:

Return multiple tags:

Return tags and other properties:

Filter for a specific tag value:

Options  (1)

MaxItems  (1)

By default, up to 10 items are returned:

Set a custom number of items:

Applications  (3)

Retrieve the index of the Wolfram Function Repository:

Search for custom functions that can generate an 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:

Translate the result into English:

Properties & Relations  (2)

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:

Create a index with labels:

Items will always share the tag of their source:

To get list of source tags, use unique tags and DeleteDuplicates:

Wolfram Research (2024), SemanticSearch, Wolfram Language function, https://reference.wolfram.com/language/ref/SemanticSearch.html.

Text

Wolfram Research (2024), SemanticSearch, Wolfram Language function, https://reference.wolfram.com/language/ref/SemanticSearch.html.

CMS

Wolfram Language. 2024. "SemanticSearch." Wolfram Language & System Documentation Center. Wolfram Research. 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_2024_semanticsearch, author="Wolfram Research", title="{SemanticSearch}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/SemanticSearch.html}", note=[Accessed: 20-January-2025 ]}

BibLaTeX

@online{reference.wolfram_2024_semanticsearch, organization={Wolfram Research}, title={SemanticSearch}, year={2024}, url={https://reference.wolfram.com/language/ref/SemanticSearch.html}, note=[Accessed: 20-January-2025 ]}