Search

Search Document Collection

POST
Search across all documents in a document collection using the document metadata and contents.

Request

This endpoint expects an object.
documentCollectionId
UUIDRequired
searchQuery
stringRequired
userEmail
stringRequired
The email of the user making the search request for permissions reduction.
metadataFilterExpression
stringOptional
The metadata search expression to filter the documents in the document collection.
searchOptions
objectOptional

Response

This endpoint returns an object
searchId
UUID
results
list of objects
POST
$curl -X POST https://api.credal.ai/api/v0/search/searchDocumentCollection \
> -H "Authorization: Bearer <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "documentCollectionId": "82e4b12a-6990-45d4-8ebd-85c00e030c24",
> "searchQuery": "ABC Corp",
> "userEmail": "jack@credal.ai",
> "metadataFilterExpression": "customerName = \'ABC Corp\'",
> "searchOptions": {
> "maxChunks": 10,
> "mergeContents": true,
> "threshold": 0.8
> }
>}'
Response
1{
2 "searchId": "76b534be-5d5c-11ee-b268-87f1fd934c81",
3 "results": [
4 {
5 "documentId": "82e4b12a-6990-45d4-8ebd-85c00e030c24",
6 "documentName": "ABC Corp - Initial meeting transcript",
7 "documentMetadata": {
8 "customerName": "ABC Corp",
9 "meetingDate": "2021-01-01T00:00:00Z"
10 },
11 "chunks": [
12 {
13 "chunkId": "8d49fa7e-f09a-4bd4-ae94-4c089c9043a0",
14 "chunkIndex": 0,
15 "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
16 "score": 0.9
17 },
18 {
19 "chunkId": "c24f99f9-2477-461b-8f8f-90a82a40879d",
20 "chunkIndex": 1,
21 "text": "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore",
22 "score": 0.8
23 },
24 {
25 "chunkId": "6413d18c-b37f-4985-9045-cc8d6e100a17",
26 "chunkIndex": 2,
27 "text": "sunt in culpa qui officia deserunt mollit anim id est laborum.",
28 "score": 0.7
29 }
30 ],
31 "mergedContents": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore. sunt in culpa qui officia deserunt mollit anim id est laborum."
32 },
33 {
34 "documentId": "90998ceb-1c10-4d2a-96cb-acf89fa3005e",
35 "documentName": "XYZ Corp - Follow-up transcript",
36 "documentMetadata": {
37 "customerName": "XYZ Corp",
38 "meetingDate": "2021-01-02T00:00:00Z"
39 },
40 "chunks": [
41 {
42 "chunkId": "3664912a-3edb-4d88-b624-80db99d383e6",
43 "chunkIndex": 0,
44 "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
45 "score": 0.7
46 },
47 {
48 "chunkId": "da9d43a4-2927-442c-8e5c-b9ef86f56fc3",
49 "chunkIndex": 1,
50 "text": "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore",
51 "score": 0.9
52 },
53 {
54 "chunkId": "8d882e9f-8eda-479b-ae2a-359ebae7b626",
55 "chunkIndex": 2,
56 "text": "sunt in culpa qui officia deserunt mollit anim id est laborum.",
57 "score": 0.75
58 }
59 ],
60 "mergedContents": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore. sunt in culpa qui officia deserunt mollit anim id est laborum."
61 }
62 ]
63}