Skip to content
grepvine.aiJoin preview

Search an index

POST
/organizations/{organization}/indexes/{index}/query
Code sample: Shell / cURL
curl --request POST \
--url 'https://api.grepvine.ai/v1/organizations/example/indexes/example/query?amount=50' \
--header 'Content-Type: application/json' \
--cookie __Host-grepvine-session=<__Host-grepvine-session> \
--data '{ "pattern": "example", "mode": "regex", "case_sensitive": true, "whole_word": false, "multiline": false, "filter": "example", "lines_before": 0, "lines_after": 0 }'
organization
required

An account or organization name. Accounts and organizations share one namespace. A name keeps the case it was created with, and any spelling that differs only in case refers to it; no other account or organization can take such a spelling.

string
/^[A-Za-z][A-Za-z0-9-]{2,62}$/
index
required

An index name, unique in its organization. A name keeps the case it was created with, and any spelling that differs only in case refers to it; no other index in the organization can take such a spelling.

string
/^[A-Za-z][A-Za-z0-9-]{0,62}$/
amount
integer
default: 50 >= 1 <= 200
page
string
<= 4096 characters
Media typeapplication/json
object
pattern
required
string
<= 8192 characters
mode
string
default: regex
Allowed values: regex literal
case_sensitive
boolean
default: true
whole_word
boolean
multiline

Let a match span lines. Without it a pattern matches within one line, ^ and $ mark the line’s edges, and a character class never matches a line break; a pattern that contains a line break is rejected. With it the pattern is matched against the whole document, ^ and $ still mark line edges, \A and \z mark the document’s edges, and a match may contain line breaks.

boolean
filter
string
<= 8192 characters
lines_before

How many lines before each result to return with it, from the same document.

integer
0 <= 20
lines_after

How many lines after each result to return with it, from the same document.

integer
0 <= 20

A page of results. Each result is one match, or several matches that share lines, together with the lines it covers.

Media typeapplication/json
object
results
required
Array<object>

One match, or several matches that share lines, together with the lines it covers. A result covers one line unless the query set multiline and a match spans lines.

object
key
required
string
revision
required
string
line_number
required

One-based number of the first line the result covers.

integer
>= 1
last_line_number
required

One-based number of the last line the result covers. Equal to line_number unless a match spans lines.

integer
>= 1
line_start_offset
required

Byte offset of the first covered line’s start within the document.

integer
line_end_offset
required

Byte offset just past the last covered line, excluding its line break.

integer
text_start_offset
required

Byte offset of the first byte of text within the document.

integer
text_line_number
required

One-based number of the line text begins on. Equal to line_number unless text was cut at its start.

integer
>= 1
text
required

The covered lines, up to 64 KiB, centered on the first match when they are longer. Line breaks between covered lines are kept; the last line’s break is not.

string
<= 65536 characters
matches
required

Every match on the covered lines that lies at least partly within text, with byte offsets and lengths relative to the document. A match that consumed the last line’s break extends one byte past text.

Array<object>
object
offset
required
integer
length
required
integer
text_truncated
required

Whether text was cut at either end.

boolean
matches_truncated
required

Whether matches were left out, because there were more than 4096 or because they lie outside text.

boolean
lines_before

The requested lines before the result, in document order, ending at the line just above its first line. Fewer are returned at the start of the document, and the field is omitted when there are none.

Array<object>

One line near a result. Text is returned whole up to 64 KiB, and up to 64 KiB away from the result; a line that extends past either bound is returned in part and marked truncated.

object
line_number
required
integer
>= 1
text
required
string
<= 65536 characters
text_truncated
required
boolean
lines_after

The requested lines after the result, in document order, starting at the line just below its last line. Fewer are returned at the end of the document, and the field is omitted when there are none.

Array<object>

One line near a result. Text is returned whole up to 64 KiB, and up to 64 KiB away from the result; a line that extends past either bound is returned in part and marked truncated.

object
line_number
required
integer
>= 1
text
required
string
<= 65536 characters
text_truncated
required
boolean
pagination
required

A page may hold fewer results than the requested amount, possibly none, while has_next is true; a query page stops at the server’s soft time budget and next_page_id resumes exactly after the last candidate it examined. Clients continue while has_next is true.

object
next_page_id
required
string
has_next
required
boolean

Example generated

{
"results": [
{
"key": "example",
"revision": "example",
"line_number": 1,
"last_line_number": 1,
"line_start_offset": 1,
"line_end_offset": 1,
"text_start_offset": 1,
"text_line_number": 1,
"text": "example",
"matches": [
{
"offset": 1,
"length": 1
}
],
"text_truncated": true,
"matches_truncated": true,
"lines_before": [
{
"line_number": 1,
"text": "example",
"text_truncated": true
}
],
"lines_after": [
{
"line_number": 1,
"text": "example",
"text_truncated": true
}
]
}
],
"pagination": {
"next_page_id": "example",
"has_next": true
}
}

The request failed. A 429 carries Retry-After; the index is busy absorbing recent writes or is out of request capacity, and clients must slow down and retry after the interval. A 403 with code organization_suspended refuses every operation on a suspended organization’s members, indexes, documents and searches; reading the organization itself still answers and reports suspended, and the client should contact support.

Media typeapplication/json
object
code
required
string
reason
required
string
error
required
string

Example generated

{
"code": "example",
"reason": "example",
"error": "example"
}
X-Request-Id
string

The request identifier used for support and audit correlation.

Retry-After
integer

Seconds to wait before retrying. Sent with every 429 so a client slows down instead of failing.