Execute Search
Searches the document repository using a structured query DSL. Supports full-text search, semantic vector search, and metadata filters — all combinable.
Request
Content-Type: application/json
| Field | Type | Default | Description |
|---|---|---|---|
where | object | — | Search/filter clause tree. |
select | string[] | See below | Fields to return. |
sort | object[] | [{_score, desc}] | Each: field + direction. |
limit | integer | 20 | Results per page (1–500). |
offset | integer | 0 | Pagination offset. |
options | object | {} | See Options below. |
Default select: ["id", "description", "doc_type", "doc_status", "reference_number", "entry_date", "_score"]
Options
| Field | Type | Default | Description |
|---|---|---|---|
include_highlights | bool | false | Return snippets with <b> tags. Needs FTS clause. |
highlight_length | int | 300 | Max chars per snippet (100–2000). |
Where clause types
Combinators
{"and": [clause, clause, ...]}
{"or": [clause, clause, ...]}
{"not": clause}
Full-text search (FTS)
{"fts": {"field": "content", "query": "supply chain risk"}}
field is always "content". The query string supports advanced syntax including phrases, proximity, and boolean operators.
Vector (semantic) search
{"vector": {"target": "content", "query": "employment applications and CVs"}}
target: "content" or "metadata". The query is embedded and compared using L2 distance. Finds conceptually similar documents even when exact keywords don't match.
Comparison operators
eq, ne, gt, gte, lt, lte — each takes field and value:
{"eq": {"field": "doc_type", "value": "Invoice"}}
{"gte": {"field": "entry_date", "value": "2025-01-01"}}
List operators
{"in": {"field": "doc_type", "value": ["Invoice", "Receipt"]}}
{"nin": {"field": "doc_status", "value": ["Draft", "Archived"]}}
String operators
{"contains": {"field": "description", "value": "urgent"}}
{"startswith": {"field": "reference_number", "value": "INV-2025"}}
Query syntax
The query string in FTS clauses supports advanced search syntax:
Keywords (implicit AND)
supply chain risk
Matches documents containing all three words (anywhere in the text, any order).
Exact phrase
"supply chain risk"
Matches the exact phrase — words must appear adjacent and in order.
OR
invoice OR receipt
Matches documents containing either word.
Exclusion (NOT)
contract -draft
Matches "contract" but excludes documents containing "draft".
Prefix matching
inv*
Matches words starting with "inv" — e.g. "invoice", "inventory", "investigation".
Proximity search (NEAR)
*N"contract penalty"
Matches documents where "contract" and "penalty" appear within 10 tokens of each other (default distance).
*N5"contract penalty"
Narrows to within 5 tokens.
Near phrase search
*NP"supply chain" "risk assessment"
Like NEAR but treats multi-word inputs as intact phrases — finds documents where the phrase "supply chain" appears near the phrase "risk assessment".
Combining syntax
"supply chain" risk -draft inv*
Exact phrase "supply chain" AND word "risk" AND NOT "draft" AND any word starting with "inv".
Search mode behaviour
| Clauses | Behaviour |
|---|---|
| FTS only | Ranked by relevance score |
| Vector only | Ranked by embedding similarity |
| FTS + Vector | Intersected, ranked by FTS |
| Metadata only | No ranking — use sort |
| FTS + Metadata | FTS with pre-filter |
| Vector + Metadata | Vector with pre-filter |
Metadata fields
doc_type, doc_status, doc_number, description, from_entity, to_entity, reference_number, entry_date, entry_person, rev_number, date, privileged, islocked, filesbelongto, subdoctype
Response
200 OK| Field | Type | Description |
|---|---|---|
total | integer | Total matching documents. |
offset | integer | Applied offset. |
limit | integer | Applied page size. |
results | array | Result objects. |
Result fields
id (always), _score, _highlights, plus any metadata field from select.
Errors
| Status | Reason |
|---|---|
| 400 | Invalid DSL |
| 401 | Invalid token |
| 504 | Query timed out |
Examples
Simple keyword search
{
"where": {"fts": {"field": "content", "query": "affidavit"}}
}
Exact phrase with highlights
{
"where": {"fts": {"field": "content", "query": "\"personal details\""}},
"select": ["id", "description", "_score", "_highlights"],
"options": {"include_highlights": true, "highlight_length": 500}
}
Proximity search — words near each other
Find documents where "contract" and "penalty" appear within 5 words:
{
"where": {"fts": {"field": "content", "query": "*N5\"contract penalty\""}}
}
Fuzzy prefix search
Match any word starting with "inv" (invoice, inventory, investigation...):
{
"where": {"fts": {"field": "content", "query": "inv*"}}
}
Boolean FTS — OR + exclusion
"invoice" or "receipt" but not "draft":
{
"where": {"fts": {"field": "content", "query": "invoice OR receipt -draft"}}
}
Vector search — document content
Find conceptually related documents by searching text content:
{
"where": {"vector": {"target": "content", "query": "employment applications and CVs"}},
"select": ["id", "description", "_score"],
"limit": 10
}
Vector search — metadata
Search against document metadata embeddings instead of full text:
{
"where": {"vector": {"target": "metadata", "query": "financial reports from Q1 2025"}},
"select": ["id", "description", "doc_type", "_score"],
"limit": 10
}
FTS + vector intersection
Only documents matching both keyword and semantic search:
{
"where": {
"and": [
{"fts": {"field": "content", "query": "risk assessment"}},
{"vector": {"target": "content", "query": "supply chain vulnerabilities"}}
]
}
}
Filter by type
{
"where": {"eq": {"field": "doc_type", "value": "Invoice"}},
"sort": [{"field": "entry_date", "direction": "desc"}]
}
Date range
{
"where": {
"and": [
{"gte": {"field": "entry_date", "value": "2025-01-01"}},
{"lt": {"field": "entry_date", "value": "2026-01-01"}}
]
}
}
FTS + metadata filter + highlights
{
"where": {
"and": [
{"fts": {"field": "content", "query": "compliance audit"}},
{"eq": {"field": "doc_type", "value": "Report"}},
{"eq": {"field": "doc_status", "value": "Final"}},
{"gte": {"field": "entry_date", "value": "2025-01-01"}}
]
},
"select": ["id", "description", "date", "_score", "_highlights"],
"options": {"include_highlights": true},
"limit": 25
}
Multiple types (IN)
{
"where": {"in": {"field": "doc_type", "value": ["Invoice", "Receipt", "Credit Note"]}}
}
Exclude statuses (NIN)
{
"where": {"nin": {"field": "doc_status", "value": ["Draft", "Archived"]}}
}
Complex nested OR + AND
Invoices from Acme Corp OR reports from 2025:
{
"where": {
"or": [
{"and": [
{"eq": {"field": "doc_type", "value": "Invoice"}},
{"eq": {"field": "from_entity", "value": "Acme Corp"}}
]},
{"and": [
{"eq": {"field": "doc_type", "value": "Report"}},
{"gte": {"field": "entry_date", "value": "2025-01-01"}}
]}
]
}
}
NOT operator
{
"where": {"not": {"eq": {"field": "from_entity", "value": "Acme Corp"}}}
}
Pagination
{
"where": {"fts": {"field": "content", "query": "contract"}},
"limit": 50,
"offset": 100
}
Full-text search on sender's documents by date
{
"where": {
"and": [
{"fts": {"field": "content", "query": "\"quarterly review\""}},
{"eq": {"field": "from_entity", "value": "Widget Inc"}},
{"gte": {"field": "date", "value": "2025-01-01"}},
{"ne": {"field": "doc_status", "value": "Draft"}}
]
},
"select": ["id", "description", "date", "doc_status", "_score", "_highlights"],
"options": {"include_highlights": true},
"sort": [{"field": "_score", "direction": "desc"}],
"limit": 25
}
cURL
curl -i -X POST \
"https://portal.docwize.com/apiv2/pub/search" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"where": {
"and": [
{"fts": {"field": "content", "query": "compliance"}},
{"eq": {"field": "doc_type", "value": "Report"}}
]
},
"select": ["id","description","_score","_highlights"],
"options": {"include_highlights": true},
"limit": 20
}'
{
"total": 142,
"offset": 0,
"limit": 20,
"results": [
{
"id": 1542,
"description": "Supply Chain Risk Assessment",
"_score": 4.238901,
"_highlights": [
"...the <b>compliance</b> audit identified..."
]
},
{
"id": 1601,
"description": "Annual Compliance Review",
"_score": 3.891204,
"_highlights": [
"...regulatory <b>compliance</b> requirements..."
]
}
]
}