{
  "lexicon": 1,
  "id": "app.bsky.feed.searchPostsV2",
  "defs": {
    "main": {
      "type": "query",
      "description": "Find posts matching a search query or filters, returning search hits for matching post records.",
      "parameters": {
        "type": "params",
        "required": [],
        "properties": {
          "cursor": {
            "type": "string",
            "description": "Optional pagination cursor."
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 25,
            "description": "Maximum number of results to return."
          },
          "query": {
            "type": "string",
            "description": "Search query string. A query or at least one filter is required."
          },
          "sort": {
            "type": "string",
            "knownValues": ["recent", "top"],
            "description": "Ranking order for results. 'recent' sorts by recency; 'top' uses search ranking."
          },
          "authors": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "at-identifier"
            },
            "description": "Include posts by any of these authors. Handles are resolved to DIDs before searching."
          },
          "mentions": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "at-identifier"
            },
            "description": "Include posts that mention any of these accounts. Handles are resolved to DIDs before searching."
          },
          "domains": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Include posts that link to any of these domains."
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "description": "Include posts that link to any of these URLs."
          },
          "embeddedAtUris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "at-uri"
            },
            "description": "Include posts that embed any of these AT URIs."
          },
          "hashtags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 640,
              "maxGraphemes": 64
            },
            "description": "Include posts tagged with any of these hashtags. Do not include the hash (#) prefix."
          },
          "excludeAuthors": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "at-identifier"
            },
            "description": "Exclude posts by any of these authors. Handles are resolved to DIDs before searching."
          },
          "excludeMentions": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "at-identifier"
            },
            "description": "Exclude posts that mention any of these accounts. Handles are resolved to DIDs before searching."
          },
          "excludeDomains": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Exclude posts that link to any of these domains."
          },
          "excludeUrls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "description": "Exclude posts that link to any of these URLs."
          },
          "excludeEmbeddedAtUris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "at-uri"
            },
            "description": "Exclude posts that embed any of these AT URIs."
          },
          "excludeHashtags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 640,
              "maxGraphemes": 64
            },
            "description": "Exclude posts tagged with any of these hashtags. Do not include the hash (#) prefix."
          },
          "since": {
            "type": "string",
            "description": "Include posts indexed at or after this timestamp. Can be a datetime, or just an ISO date (YYYY-MM-DD)."
          },
          "until": {
            "type": "string",
            "description": "Include posts indexed before this timestamp. Defaults to the current time. Can be a datetime, or just an ISO date (YYYY-MM-DD)."
          },
          "allTime": {
            "type": "boolean",
            "description": "Search the full index instead of the recent-post window."
          },
          "languages": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "language"
            },
            "description": "Include posts whose language matches any of these language codes."
          },
          "excludeLanguages": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "language"
            },
            "description": "Exclude posts whose language matches any of these language codes."
          },
          "hasMedia": {
            "type": "boolean",
            "description": "Include only posts with media."
          },
          "hasVideo": {
            "type": "boolean",
            "description": "Include only posts with video."
          },
          "replyParentUri": {
            "type": "string",
            "format": "at-uri",
            "description": "Include only direct replies to this parent post URI."
          },
          "threadRootUri": {
            "type": "string",
            "format": "at-uri",
            "description": "Include only posts in the thread rooted at this post URI."
          },
          "excludeReplies": {
            "type": "boolean",
            "description": "Exclude replies from results. Mutually exclusive with repliesOnly."
          },
          "repliesOnly": {
            "type": "boolean",
            "description": "Include only replies. Mutually exclusive with excludeReplies."
          },
          "following": {
            "type": "boolean",
            "description": "Include only posts from accounts followed by the viewer."
          },
          "queryLanguage": {
            "type": "string",
            "knownValues": ["ja", "zh", "ko", "th", "ar"],
            "description": "Language analyzer hint for the query text. If unset, the server auto-detects when possible."
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": ["posts"],
          "properties": {
            "cursor": {
              "type": "string",
              "description": "Cursor for the next page of results."
            },
            "hitsTotal": {
              "type": "integer",
              "description": "Estimated total number of matching hits. May be rounded or truncated."
            },
            "posts": {
              "type": "array",
              "items": {
                "type": "ref",
                "ref": "app.bsky.feed.defs#postView"
              },
              "description": "Hydrated views of matching posts."
            },
            "detectedQueryLanguages": {
              "type": "array",
              "items": {
                "type": "string",
                "knownValues": ["ja", "zh", "ko", "th", "ar"]
              },
              "description": "Query languages detected for CJK, Thai, or Arabic text. Empty or omitted for other scripts."
            }
          }
        }
      },
      "errors": [{ "name": "BadQueryString" }]
    }
  }
}

