SKEG · GUIDES

Improve search quality and response time

Change search effort, check the articles found and choose a setting for your load.

Skeg 0.8 · Development documentation

Use l_search to control how broadly a graph search explores candidates. Choose a value using representative queries and an exact reference ranking. If an expected row is missing, first check the data, tenant, embedding model and filter using search troubleshooting.

Check which plan runs

SKEG.VSEARCH <index> <k> <l_search> <query>

k sets the maximum number of hits. l_search sets the requested effort for the graph walk. Zero uses the disk index’s default. Read the default with SKEG.VINDEX.INFO <index> and the server’s limits with SKEG.CAPABILITIES. Skeg clamps k and l_search to their advertised limits.

Run the query with EXPLAIN to see which plan ran. When a graph walk runs, the profile shows the effective l, including when it came from the index default or was clamped. If the plan ran without a graph walk, inspect the filter and candidate counts for that plan. See query diagnostics.

flowchart TD
    accTitle: Choose what to inspect in a search plan
    accDescr: Run the query with EXPLAIN. If a graph walk ran, compare explicit effort settings. Otherwise inspect the filter and candidate counts.
    A["Run the query with EXPLAIN"] --> B{"Graph walk ran?"}
    B -->|Yes| C["Compare explicit effort values"]
    B -->|No| D["Inspect filter and candidates"]

To try the argument in the small first-search example, add this after the script defines query. Keep the requested hit count at two and print the IDs for each effort value.

for effort in (0, 64, 128):
    hits = client.execute_command("SKEG.VSEARCH", index, 2, effort, query)
    ids = [int(row_id) for row_id in hits[::2]]
    print(effort, ids)

The example may return the same two IDs in each case. Use it to check how to send the setting, then use representative data to choose a value.

Build an exact reference

For each query, score every eligible vector with the same cosine metric and filter as the application. Sort by score and keep up to k IDs. Compute this reference independently of approximate search. Define how to handle ties at the cutoff before comparing results.

Recall is the share of exact reference IDs that appeared in the response:

recall⁡(q)=∣R(q)∩T(q)∣∣T(q)∣\operatorname{recall}(q) = \frac{|R(q) \cap T(q)|}{|T(q)|}

Here T(q)T(q) contains the exact reference IDs and R(q)R(q) contains the returned IDs. If the exact result is [3, 4] and the response is [3], recall is one half. For queries with fewer than k eligible rows, divide by the actual reference size. If the reference is empty, record that case separately and check that the response is empty.

This measures agreement with exact vector ranking. Use labelled queries if you also need to measure whether users find the results relevant.

Compare effort settings

Keep the data, index, query set, k, filters and payload-return settings fixed. Keep concurrency, cache state and maintenance conditions comparable. Include the default path (l_search=0) if the application uses it.

Record these fields for each query:

FieldWhat to keep
RequestQuery ID, k, requested effort and filter
ResultReference IDs, returned IDs and recall for successful requests
TimingClient-observed duration and units
OutcomeSuccess, timeout, refusal or another error
PlanEffective graph effort when reported and the relevant candidate counts from a separate EXPLAIN run

Compare recall and client latency for each setting, and count failures separately. Keep the observation count with latency summaries. Take EXPLAIN profiles on a separate pass so the timed requests match the ones the application will send.

Choose and verify a setting

  1. Keep the settings that meet the application’s recall requirement.
  2. Compare client latency and failure counts for those settings.
  3. Repeat the selected setting at the expected concurrency and request rate.
  4. Investigate outliers by query ID and inspect their plans with EXPLAIN.

A wider graph walk can improve coverage and can take more time. Compare the observed results for each setting. Repeat the check after changing the index, embedding model, filters or query load. When comparing versions, record both the requested and effective effort since the default can differ between indexes.

For the response format and score interpretation, see search requests and results. For eligibility rules, see payloads and filters.