Skip to main content

Execute Search

POST/apiv2/pub/searchsearch

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

FieldTypeDefaultDescription
whereobjectSearch/filter clause tree.
selectstring[]See belowFields to return.
sortobject[][{_score, desc}]Each: field + direction.
limitinteger20Results per page (1–500).
offsetinteger0Pagination offset.
optionsobject{}See Options below.

Default select: ["id", "description", "doc_type", "doc_status", "reference_number", "entry_date", "_score"]

Options

FieldTypeDefaultDescription
include_highlightsboolfalseReturn snippets with <b> tags. Needs FTS clause.
highlight_lengthint300Max 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": {"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.

*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

ClausesBehaviour
FTS onlyRanked by relevance score
Vector onlyRanked by embedding similarity
FTS + VectorIntersected, ranked by FTS
Metadata onlyNo ranking — use sort
FTS + MetadataFTS with pre-filter
Vector + MetadataVector 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
FieldTypeDescription
totalintegerTotal matching documents.
offsetintegerApplied offset.
limitintegerApplied page size.
resultsarrayResult objects.

Result fields

id (always), _score, _highlights, plus any metadata field from select.


Errors

StatusReason
400Invalid DSL
401Invalid token
504Query timed out

Examples

{
"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\""}}
}

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..."
]
}
]
}
{
"detail": "Unknown field 'DocType' in 'eq' clause. Field names must be lowercase snake_case (e.g. doc_type)."
}
{
"detail": "Gateway Timeout"
}