# Filtered Search

> USearch for Go

A `Predicate` in the `DenseSearchConfig` admits only the keys it approves.
Non-matching entries still route the traversal, so recall does not collapse at low selectivity.

```go
admits := func(key usearch.Key) bool {
	value, integral := key.Uint64()
	return integral && value%2 == 0
}
matches, err := index.On(executor).Search(queries, 10, arena, &usearch.DenseSearchConfig{Predicate: admits})
```

The predicate runs on the library's worker threads, so it must be safe for concurrent use.

Every long verb's config takes a `Progress` handler, called with the units finished so far and the units the call finishes if it runs to the end; answering `false` stops it wherever the verb can stop, which an `Insert` cannot.

```go
deadline := time.Now().Add(30 * time.Second)
report, err := index.On(executor).Refine(&usearch.DenseRefineConfig{
	ExpansionFactor: 128,
	Progress:        func(completed, total uint) bool { return time.Now().Before(deadline) },
})
```

A handler never runs on two threads at once, so it may carry a counter or a deadline without a lock.
A panic inside a predicate, a handler or a value lookup is recovered where it is raised and read as a rejection, a stop or a missing row, since unwinding it through the library's frames would skip their unlocks.
The first such panic becomes the call's error once the call is final, the panic itself when it is an `error`.

`import "github.com/unum-cloud/USearch/golang"`

## Predicate

Predicate admits a candidate key into a filtered search, or passes over it.

```go
type Predicate func(key Key) bool
```

It runs on the executor's threads together, so it must be safe for concurrent use, and a panic inside it rejects the key and becomes the call's error.

## ProgressCallback

ProgressCallback is called with the units a long call finished so far and the units it finishes unless stopped; false stops it wherever the verb can stop.

```go
type ProgressCallback func(completed, total uint) bool
```

It never runs on two threads at once, and a panic inside it stops the call and becomes its error.

