query

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package query builds the Bleve search request from user input (positional terms + repeatable --field filters) and renders results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderText

func RenderText(w io.Writer, r *Result) error

RenderText writes a terse, human-readable rendering of r to w. One hit per block: rank, score, path on the first line; title on the second; snippet on the third (if present).

Types

type Hit

type Hit struct {
	Path    string              `json:"path"`
	Score   float64             `json:"score"`
	Title   string              `json:"title,omitempty"`
	Tags    []string            `json:"tags,omitempty"`
	Snippet string              `json:"snippet,omitempty"`
	Extras  map[string]any      `json:"extras,omitempty"`
	Frags   map[string][]string `json:"fragments,omitempty"`
}

Hit is one ranked search result.

type Request

type Request struct {
	Terms     string             // positional query string; empty -> match all
	Fields    map[string]string  // exact-match filters AND'd with the query
	Limit     int                // 0 -> 10
	NoSnippet bool               // disable highlight extraction
	Boosts    map[string]float64 // field -> boost (only applied when > 0)
	Highlight string             // "ansi", "html", or "" (empty disables)
}

Request describes a single search.

type Result

type Result struct {
	Total uint64 `json:"total"`
	Hits  []Hit  `json:"hits"`
}

Result is the response shape returned to the CLI and MCP layers.

func Search(idx *index.Index, req Request) (*Result, error)

Search runs the request against idx and returns ranked hits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL