Skip to main content
POST
/
db
/
semantic-search
JavaScript
const response = await fetch('https://api.worqhat.com/db/semantic-search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    query: 'Find products related to machine learning',
    table: 'products',
    limit: 10,
    threshold: 0.7,
    environment: 'production'
  })
});
const data = await response.json();
{
  "success": true,
  "results": [
    {
      "table": "products",
      "record": {},
      "similarity": 0.847,
      "_meta": {
        "matched_fields": [
          "title",
          "description"
        ]
      }
    }
  ],
  "query_embedding_preview": [
    0.123,
    -0.456,
    0.789,
    -0.321,
    0.654
  ],
  "executionTime": 245
}

Authorizations

Authorization
string
header
required

API key authentication. Format - "Bearer YOUR_API_KEY"

Body

application/json
query
string
required

Natural language search query

Example:

"Find products related to machine learning"

table
string

Single table to search in (optional if tables is provided)

Example:

"products"

tables
string[]

Multiple tables to search across (optional if table is provided)

Example:
["products", "articles", "documents"]
limit
number
default:10

Maximum number of results to return

Required range: 1 <= x <= 100
threshold
number
default:0.7

Minimum similarity score threshold

Required range: 0 <= x <= 1
filters
object

Additional WHERE conditions to apply

Example:
{
"category": "electronics",
"price": { "min": 100, "max": 500 }
}
environment
enum<string>

Environment to search in (development, staging, production)

Available options:
development,
staging,
production
Example:

"production"

Response

Semantic search completed successfully

success
boolean
Example:

true

results
object[]
query_embedding_preview
number[]

First 5 dimensions of the query embedding

Example:
[0.123, -0.456, 0.789, -0.321, 0.654]
executionTime
number

Search execution time in milliseconds

Example:

245