Search a project
Send a question with POST. Grape gives the passages in order of relevance.
Endpoint
POST /v1/projects/{project}/searchExample
Send JSON with Content-Type: application/json. The response shows only two passages.
curl -X POST https://grape-inc.in/v1/projects/$PROJECT/search \
-H "Authorization: Bearer $GRAPE_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "How many hearts does an octopus have?", "limit": 2}'{
"hits": [
{ "projectId": "0198...", "projectName": "Animals", "path": "Octopus.txt", "page": 1, "score": 4.21,
"snippet": "... They have three hearts; a systemic or main heart ..." },
{ "projectId": "0198...", "projectName": "Animals", "path": "Squid.txt", "page": 1, "score": 2.87,
"snippet": "Squid have three hearts, like the octopus ..." }
]
}Request fields
| Field | Type | Description |
|---|---|---|
| query | string | The question in plain words. A page matches when it has any word of the question. Use query or queries. |
| queries | array | Use this or query: one question for each part. Grape searches all the parts together. |
| paths | array | Optional. Search only these files, or the files in these folders. |
| limit | number | The number of passages to return. The default is 6. |
| snippetCharacters | number | Cuts each passage to approximately this number of characters, around the match. |
Response fields
| Field | Type | Description |
|---|---|---|
| hits | array | The pages in order of relevance (BM25). |
| hits[].path | string | The file. |
| hits[].page | number | The page of the file. A file without pages has page 1. |
| hits[].score | number | The BM25 score. A higher score is a better match. |
| hits[].snippet | string | The part of the page around the match. |
| hits[].projectId | string | The ID of the project. |
Search in the language of your documents. For a question in a different language, translate it first, with the words of the documents.