Skip to content
Framework Docs

Grep File

client.Beta.Retrieval.Grep(ctx, params) (*PaginatedCursorPost[BetaRetrievalGrepResponse], error)
POST/api/v1/retrieval/files/grep

Grep within a file’s parsed content using a regex pattern.

ParametersExpand Collapse
params BetaRetrievalGrepParams
FileID param.Field[string]

Body param: ID of the file to grep.

IndexID param.Field[string]

Body param: ID of the index the file belongs to.

Pattern param.Field[string]

Body param: Regex pattern to search for.

OrganizationID param.Field[string]Optional

Query param

formatuuid
ProjectID param.Field[string]Optional

Query param

formatuuid
ContextChars param.Field[int64]Optional

Body param: Number of characters of context to include before and after the matched pattern in the content field of the response

PageSize param.Field[int64]Optional

Body param: The maximum number of items to return. The service may return fewer than this value. If unspecified, a default page size will be used. The maximum value is typically 1000; values above this will be coerced to the maximum.

PageToken param.Field[string]Optional

Body param: A page token, received from a previous list call. Provide this to retrieve the subsequent page.

ReturnsExpand Collapse
type BetaRetrievalGrepResponse struct{…}

A single grep match within a file.

Content string

Matched text content.

EndChar int64

End character offset of the match.

StartChar int64

Start character offset of the match.

Grep File

package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Beta.Retrieval.Grep(context.TODO(), llamacloudprod.BetaRetrievalGrepParams{
    FileID: "file_id",
    IndexID: "idx-abc123",
    Pattern: "revenue|profit",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "items": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
Returns Examples
{
  "items": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}