> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://stelltec.com/rhebok/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://stelltec.com/rhebok/docs/_mcp/server.

# Search the index

GET http://127.0.0.1:7331/api/search

Runs a query the way the prompt hook does, with the hook's threshold and
token budget, and returns what each retrieval stage found, the fused
list that cleared the gate, and which chunks would be injected. A
failure the user can act on (embedding unavailable, a pack that must be
rebuilt, a missing vector extension, an empty query) is a 200 with only
an `error` field.


Reference: https://stelltec.com/rhebok/docs/api/search

## Request

### Query parameters

- `q` (string, required) — The query text. An empty or whitespace-only value returns `{"error": "empty query"}`. If `q` is given more than once, the last one is used.
- `tier` (integer, optional) — Quality tier to search with: 0 `instant`, 1 `fast`, 2 `balanced`, 3 `thorough`, 4 `exhaustive`. Values above 4 are treated as 4. A value that is not an integer from 0 to 255 is ignored. Without it, the hook's configured tier is used. If given more than once, the last one is used.

## Response

### 200

The search ran, or failed in a way that is reported in `error`.

- `SearchResult`
  - SearchExplain: SearchExplain
  - SearchFailed: SearchFailed

## Errors

### 421 Misdirected Request Error

The `Host` header does not name this dashboard (see the rules at the top of this page).

- `error` (string, required) — What went wrong, in plain words.

### 503 Service Unavailable Error

The index store could not be opened or read right now. A retry can succeed.

- `error` (string, required) — What went wrong, in plain words.

## Types

### SearchExplain

- `stages` (list of StageTrace, required)
- `fused` (list of HitSummary, required) — Every hit that cleared the relevance gate and survived diversity selection.
- `threshold` (double, required) — The relevance gate the hook uses.
- `injected` (list of string, required) — The chunk ids of the leading hits in `fused` that fit the hook's token budget, which is what the hook would put in the prompt.
- `degraded` (boolean, required) — True when the tier's time budget forced a stage to be skipped.
- `bm25_unavailable` (string, required, nullable) — Why keyword search could not run, or null.
- `vectors_unavailable` (string, required, nullable) — Why vector search could not run, or null.
- `memory_unavailable` (string, required, nullable) — Why the memory pack could not be searched, or null.
- `elapsed_ms` (integer, required) — Pipeline time in milliseconds.

### SearchFailed

- `error` (string, required) — `empty query`, `embedding unavailable`, a pack refusal that names the command to repair it, or the missing-vector-extension message.

### StageTrace

- `name` (string, required) — The stage, for example `vector`, `bm25`, `graph` or `fused`. A stage that did not run is not listed.
- `hits` (list of HitSummary, required)

### HitSummary

- `chunk_id` (string, required) — `<doc_id>:<ordinal>`.
- `doc_id` (string, required)
- `title` (string, required)
- `heading` (string, required) — The chunk's heading path.
- `source_type` (string, required) — The kind of source a document came from. Graph nodes also use `project` for project nodes.
- `relevance` (double, required) — A 0-1 cosine-derived value. It drives the injection gate and the final order.
- `score` (double, required) — The fusion rank value. It only orders candidates and is not on the same scale as `relevance`.
- `excerpt` (string, required)
- `memory_kind` (string, required, nullable) — For a memory hit, `lesson`, `fact` or `episode`; otherwise null.

## Examples

### A search that found and injected two chunks

**Response**

```json
{
  "bm25_unavailable": null,
  "degraded": false,
  "elapsed_ms": 94,
  "fused": [
    {
      "chunk_id": "3f9a1c0be47d2a5591c8e0f6a7b3d214:2",
      "doc_id": "3f9a1c0be47d2a5591c8e0f6a7b3d214",
      "excerpt": "A release is a version bump merged to main; there is no tag step...",
      "heading": "How we ship > Releases",
      "memory_kind": null,
      "relevance": 0.8412,
      "score": 0.0328,
      "source_type": "markdown",
      "title": "How we ship"
    },
    {
      "chunk_id": "9c04e7d1aa3b46f28e5d0c71b2f9a863:0",
      "doc_id": "9c04e7d1aa3b46f28e5d0c71b2f9a863",
      "excerpt": "One commit per pull request; squash before you open it.",
      "heading": "",
      "memory_kind": "lesson",
      "relevance": 0.7731,
      "score": 0.0161,
      "source_type": "memory",
      "title": "Squash PRs, no prefixes"
    }
  ],
  "injected": [
    "3f9a1c0be47d2a5591c8e0f6a7b3d214:2",
    "9c04e7d1aa3b46f28e5d0c71b2f9a863:0"
  ],
  "memory_unavailable": null,
  "stages": [
    {
      "hits": [
        {
          "chunk_id": "3f9a1c0be47d2a5591c8e0f6a7b3d214:2",
          "doc_id": "3f9a1c0be47d2a5591c8e0f6a7b3d214",
          "excerpt": "A release is a version bump merged to main; there is no tag step...",
          "heading": "How we ship > Releases",
          "memory_kind": null,
          "relevance": 0.8412,
          "score": 0.0328,
          "source_type": "markdown",
          "title": "How we ship"
        }
      ],
      "name": "vector"
    },
    {
      "hits": [],
      "name": "bm25"
    },
    {
      "hits": [
        {
          "chunk_id": "3f9a1c0be47d2a5591c8e0f6a7b3d214:2",
          "doc_id": "3f9a1c0be47d2a5591c8e0f6a7b3d214",
          "excerpt": "A release is a version bump merged to main; there is no tag step...",
          "heading": "How we ship > Releases",
          "memory_kind": null,
          "relevance": 0.8412,
          "score": 0.0328,
          "source_type": "markdown",
          "title": "How we ship"
        }
      ],
      "name": "fused"
    }
  ],
  "threshold": 0.66,
  "vectors_unavailable": null
}
```

**SDK Code**

```python A search that found and injected two chunks
import requests

url = "http://127.0.0.1:7331/api/search"

querystring = {"q":"how do we ship a release","tier":"1"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript A search that found and injected two chunks
const url = 'http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go A search that found and injected two chunks
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby A search that found and injected two chunks
require 'uri'
require 'net/http'

url = URI("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java A search that found and injected two chunks
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")
  .asString();
```

```php A search that found and injected two chunks
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1');

echo $response->getBody();
```

```csharp A search that found and injected two chunks
using RestSharp;

var client = new RestClient("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift A search that found and injected two chunks
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Ollama is not reachable

**Response**

```json
{
  "error": "embedding unavailable"
}
```

**SDK Code**

```python Ollama is not reachable
import requests

url = "http://127.0.0.1:7331/api/search"

querystring = {"q":"how do we ship a release","tier":"1"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript Ollama is not reachable
const url = 'http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Ollama is not reachable
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Ollama is not reachable
require 'uri'
require 'net/http'

url = URI("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java Ollama is not reachable
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")
  .asString();
```

```php Ollama is not reachable
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1');

echo $response->getBody();
```

```csharp Ollama is not reachable
using RestSharp;

var client = new RestClient("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift Ollama is not reachable
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### No query text

**Response**

```json
{
  "error": "empty query"
}
```

**SDK Code**

```python No query text
import requests

url = "http://127.0.0.1:7331/api/search"

querystring = {"q":"how do we ship a release","tier":"1"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript No query text
const url = 'http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go No query text
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby No query text
require 'uri'
require 'net/http'

url = URI("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java No query text
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")
  .asString();
```

```php No query text
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1');

echo $response->getBody();
```

```csharp No query text
using RestSharp;

var client = new RestClient("http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift No query text
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://127.0.0.1:7331/api/search?q=how+do+we+ship+a+release&tier=1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```