Typesensory.Api.Documents (Typesensory v0.1.0)

API calls for all endpoints tagged Documents.

Link to this section Summary

Functions

Delete a document Delete an individual document from a collection by using its ID.

Delete a bunch of documents Delete a bunch of documents that match a specific filter condition. Use the batch_size parameter to control the number of documents that should deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server.

Export all documents in a collection Export all documents in a collection in JSON lines format.

Retreive a document Fetch an individual document from a collection by using its ID.

Retrieve a single search override Retrieve the details of a search override, given its id.

Retrieve a single search synonym Retrieve the details of a search synonym, given its id.

Import documents into a collection The documents to be imported must be formatted in a newline delimited JSON structure. You can feed the output file from a Typesense export operation directly as import.

Index a document A document to be indexed in a given collection must conform to the schema of the collection.

send multiple search requests in a single HTTP request This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests. You can also use this feature to do a federated search across multiple collections in a single HTTP request.

Search for documents in a collection Search for documents in a collection that match the search criteria.

Update a document Update an individual document from a collection by using its ID. The update can be partial.

Update documents with conditional query The filter_by query parameter is used to filter to specify a condition against which the documents are matched. The request body contains the fields that should be updated for any documents that match the filter condition. This endpoint is only available if the Typesense server is version 0.25.0.rc12 or later.

Create or update an override to promote certain documents over others Create or update an override to promote certain documents over others. Using overrides, you can include or exclude specific documents for a given query.

Create or update a synonym Create or update a synonym to define search terms that should be considered equivalent.

Link to this section Functions

Link to this function

delete_document(connection, collection_name, document_id, opts \\ [])

@spec delete_document(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Map.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Delete a document Delete an individual document from a collection by using its ID.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to search for the document under
  • document_id (String.t): The Document ID
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, map()} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

delete_documents(connection, collection_name, opts \\ [])

Delete a bunch of documents Delete a bunch of documents that match a specific filter condition. Use the batch_size parameter to control the number of documents that should deleted at a time. A larger value will speed up deletions, but will impact performance of other operations running on the server.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to delete documents from
  • opts (keyword): Optional parameters
    • :deleteDocumentsParameters (DeleteDocumentsDeleteDocumentsParametersParameter):

returns

Returns

  • {:ok, Typesensory.Model.DeleteDocuments200Response.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

delete_search_override(connection, collection_name, override_id, opts \\ [])

@spec delete_search_override(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.ApiResponse.t()}
  | {:ok, Typesensory.Model.SearchOverride.t()}
  | {:error, Tesla.Env.t()}

Delete an override associated with a collection

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • override_id (String.t): The ID of the search override to delete
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchOverride.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

delete_search_synonym(connection, collection_name, synonym_id, opts \\ [])

@spec delete_search_synonym(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.SearchSynonym.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Delete a synonym associated with a collection

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • synonym_id (String.t): The ID of the search synonym to delete
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchSynonym.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

export_documents(connection, collection_name, opts \\ [])

@spec export_documents(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.ApiResponse.t()}
  | {:ok, String.t()}
  | {:error, Tesla.Env.t()}

Export all documents in a collection Export all documents in a collection in JSON lines format.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • opts (keyword): Optional parameters
    • :exportDocumentsParameters (ExportDocumentsExportDocumentsParametersParameter):

returns

Returns

  • {:ok, String.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_document(connection, collection_name, document_id, opts \\ [])

@spec get_document(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Map.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Retreive a document Fetch an individual document from a collection by using its ID.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to search for the document under
  • document_id (String.t): The Document ID
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, map()} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_search_override(connection, collection_name, override_id, opts \\ [])

@spec get_search_override(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.SearchOverride.t()} | {:error, Tesla.Env.t()}

Retrieve a single search override Retrieve the details of a search override, given its id.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • override_id (String.t): The id of the search override
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchOverride.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_search_overrides(connection, collection_name, opts \\ [])

@spec get_search_overrides(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.SearchOverridesResponse.t()} | {:error, Tesla.Env.t()}

List all collection overrides

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchOverridesResponse.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_search_synonym(connection, collection_name, synonym_id, opts \\ [])

@spec get_search_synonym(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.SearchSynonym.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Retrieve a single search synonym Retrieve the details of a search synonym, given its id.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • synonym_id (String.t): The id of the search synonym
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchSynonym.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_search_synonyms(connection, collection_name, opts \\ [])

@spec get_search_synonyms(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.SearchSynonymsResponse.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

List all collection synonyms

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchSynonymsResponse.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

import_documents(connection, collection_name, body, opts \\ [])

@spec import_documents(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.ApiResponse.t()}
  | {:ok, String.t()}
  | {:error, Tesla.Env.t()}

Import documents into a collection The documents to be imported must be formatted in a newline delimited JSON structure. You can feed the output file from a Typesense export operation directly as import.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • body (String.t): The json array of documents or the JSONL file to import
  • opts (keyword): Optional parameters
    • :importDocumentsParameters (ImportDocumentsImportDocumentsParametersParameter):

returns

Returns

  • {:ok, String.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

index_document(connection, collection_name, body, opts \\ [])

@spec index_document(
  Tesla.Env.client(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, Map.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Index a document A document to be indexed in a given collection must conform to the schema of the collection.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to add the document to
  • body (map()): The document object to be indexed
  • opts (keyword): Optional parameters
    • :action (String.t): Additional action to perform

returns

Returns

  • {:ok, map()} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

multi_search(connection, multi_search_parameters, opts \\ [])

@spec multi_search(Tesla.Env.client(), %{optional(String.t()) => any()}, keyword()) ::
  {:ok, Typesensory.Model.ApiResponse.t()}
  | {:ok, Typesensory.Model.MultiSearchResult.t()}
  | {:error, Tesla.Env.t()}

send multiple search requests in a single HTTP request This is especially useful to avoid round-trip network latencies incurred otherwise if each of these requests are sent in separate HTTP requests. You can also use this feature to do a federated search across multiple collections in a single HTTP request.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • multi_search_parameters (MultiSearchParameters):
  • opts (keyword): Optional parameters
    • :body (MultiSearchSearchesParameter):

returns

Returns

  • {:ok, Typesensory.Model.MultiSearchResult.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

search_collection(connection, collection_name, search_parameters, opts \\ [])

@spec search_collection(
  Tesla.Env.client(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, Typesensory.Model.ApiResponse.t()}
  | {:ok, Typesensory.Model.SearchResult.t()}
  | {:error, Tesla.Env.t()}

Search for documents in a collection Search for documents in a collection that match the search criteria.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to search for the document under
  • search_parameters (SearchParameters):
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchResult.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

update_document(connection, collection_name, document_id, body, opts \\ [])

@spec update_document(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, Map.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Update a document Update an individual document from a collection by using its ID. The update can be partial.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to search for the document under
  • document_id (String.t): The Document ID
  • body (map()): The document object with fields to be updated
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, map()} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

update_documents(connection, collection_name, body, opts \\ [])

@spec update_documents(
  Tesla.Env.client(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, Typesensory.Model.ApiResponse.t()}
  | {:ok, Typesensory.Model.UpdateDocuments200Response.t()}
  | {:error, Tesla.Env.t()}

Update documents with conditional query The filter_by query parameter is used to filter to specify a condition against which the documents are matched. The request body contains the fields that should be updated for any documents that match the filter condition. This endpoint is only available if the Typesense server is version 0.25.0.rc12 or later.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to update documents in
  • body (map()): The document fields to be updated
  • opts (keyword): Optional parameters
    • :updateDocumentsParameters (UpdateDocumentsUpdateDocumentsParametersParameter):

returns

Returns

  • {:ok, Typesensory.Model.UpdateDocuments200Response.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

upsert_search_override(connection, collection_name, override_id, search_override_schema, opts \\ [])

Create or update an override to promote certain documents over others Create or update an override to promote certain documents over others. Using overrides, you can include or exclude specific documents for a given query.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • override_id (String.t): The ID of the search override to create/update
  • search_override_schema (SearchOverrideSchema): The search override object to be created/updated
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchOverride.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

upsert_search_synonym(connection, collection_name, synonym_id, search_synonym_schema, opts \\ [])

Create or update a synonym Create or update a synonym to define search terms that should be considered equivalent.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection
  • synonym_id (String.t): The ID of the search synonym to create/update
  • search_synonym_schema (SearchSynonymSchema): The search synonym object to be created/updated
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.SearchSynonym.t} on success
  • {:error, Tesla.Env.t} on failure