in filter (see example).
Semantic search works by comparing the semantic meaning of the search query to the semantic meaning of the document passages. The document passages are automatically derived and indexed upon file uploads (PDF only).
A natural flow would be:
- Upload a document
- Query
/documents/statusto check if the document is ready (see beta documentation) - Query
/documents/passages/searchto find relevant passages in the document(s)
Passages search offers semantic search filters
This endpoint requires a list of document ids that you want to do semantic search on. You can not currently search through all passages for the entire project in a single query.
Ordering
Search results are ranked by relevance, with the most relevant appearing first. How relevance is determined depends on the filter you choose:- Lexical Search Filter: This filter looks for exact word matches, making it ideal for finding specific dates, names, or keywords. Use this when you know exactly what you’re looking for. This is the default search behavior for the Documents API.
- Semantic Search Filter: This filter understands the meaning behind words and phrases, even if they don’t match exactly. It’s useful for broader searches or when you’re looking for related ideas or concepts.
Examples
The following request will return document passages matching the specified search query for the document ids 1, 2, and 3.lexicalSearch filter. This helps with edge cases where it’s hard to extract meaning such as numbers (eg. dates), names, etc.
Filtering
Filtering uses a special JSON filtering language. It’s flexible and consists of a number of different “leaf” filters, which can be combined arbitrarily using the boolean clausesand. This is the same filters used in the search, list and aggregate endpoints, with some restrictions and the addition of “semanticSearch” filter.
Supported leaf filters
equals
equals
Only includes results that are equal to the specified value. Supported fields: Non-array type fields.
in
in
Only includes results that are equal to one of the specified values. Supported fields: Non-array type fields.
semanticSearch
semanticSearch
Supported fields:
content.lexicalSearch
lexicalSearch
Supported fields:
content.Properties
The following overview shows the properties you can filter on and which filter applies to which property.| Property | Type | Applicable filters |
|---|---|---|
["document", "id"] | integer | equals, in |
["document", "externalId"] | string | equals, in |
["document", "instanceId"] | object | equals, in |
["type"] | string | equals |
["content"] | string | semanticSearch, lexicalSearch |