Searching

Semantic searching of documents

Last updated: 16 June 2022

Searching vs Querying

Viko supports two types of query - question answering and searching. This document relates to searching. Read more about question answering vs searching

The examples in this document use the stubbed endpoint. Remember to switch over to the real endpoint !


Search for a relevant document and snippet.

Filters can be applied to restrict the document sources (context)

Request

GET https://api.viko.ai/v1-beta/{tenancy}/search/
Parameters: tenancy
Header: X-Api-Key (required)
Content-Type: application/json
Body: JSON object

{
  text: string (required)
  filter: {
    canonical_urls: Array<string> (optional)
    folders: Array<string> (optional)
  }
}

Note: The sezrch context is a union of all those documents matching a filter. Put another way we apply an implicit OR clause to filters i.e. any document with a matching canonical_url or in one of the folders.

Response

Status: 200
Body: JSON array

{
  "results": [
    {
      id: string (required) // matching document id
      context: string (optional) // snippet
      confidence: float (required) // 0 to 1
    }
  ]
}

Example

$ curl --location \
  --header'X-Api-Key: replaceme' \
  --header 'Content-Type: application/json' \
  --request POST 'https://stub.viko.ai/v1-beta/acme/search/' \  
  --data-raw '{
      "text": "shipping prices",
      "filters": {
          "canonical_urls": [
              "https://acme.com/shipping.html"
          ],
          "folders": [
              "shipping"
          ]
      }
  }'
{
  "id": "1",
  "context": "Lorem ipsum next day shipping is available for $4.95 Lorem ipsum",
  "confidence": 0.85
}

Try Viko

Want to see Viko in action? Try our interactive demo