# `Arcadic.FullText`
[🔗](https://github.com/baselabs/arcadic/blob/baselabs_arcadic-v4.0.1/lib/arcadic/full_text.ex#L5)

ArcadeDB full-text search — tenant-blind `FULL_TEXT` (Lucene) index DDL and
`SEARCH_INDEX`/`SEARCH_FIELDS` query builders, parallel to `Arcadic.Vector`.

The query text and candidate RID list bind as the SQL parameters `:q` and `:rids`.
The index reference `"Type[property]"` and analyzer class name are interpolated only
after identifier and dotted-class-name validation. A `FULL_TEXT` index **retro-indexes rows
that already exist**. Use a SQL-capable connection, such as HTTP.

`search/5`'s `property_or_properties` must match an existing FULL_TEXT index by NAME: a
single-property index is `Type[prop]`, a composite `create_index(conn, T, [a, b])` is `Type[a,b]`
(search it with the same list). `SEARCH_INDEX` on a ref with no matching index is a server
`SchemaException`. `search_fields/5` names the fields directly and needs no exact index-name match.
Both searches accept a `:filter` list of candidate RIDs. An empty candidate set returns
`{:ok, []}` without a request.

# `create_index`

```elixir
@spec create_index(Arcadic.Conn.t(), String.t(), String.t() | [String.t()], keyword()) ::
  :ok | {:error, atom() | Exception.t()}
```

Creates a `FULL_TEXT` index on `type` over one property or a list of properties (idempotent —
`IF NOT EXISTS` unless `if_not_exists: false`). `opts`: `:if_not_exists` (bool, default true),
`:analyzer` (a friendly atom — `:standard`/`:english`/`:keyword`/`:whitespace`/`:simple` — or a
Lucene FQCN string). Retro-indexes existing rows. Value-free on a bad identifier / analyzer / opt.

# `create_index!`

```elixir
@spec create_index!(
  Arcadic.Conn.t(),
  String.t(),
  String.t() | [String.t()],
  keyword()
) :: :ok
```

Creates a FULL_TEXT index, raising on error.

# `drop_index`

```elixir
@spec drop_index(Arcadic.Conn.t(), String.t(), String.t() | [String.t()]) ::
  :ok | {:error, atom() | Exception.t()}
```

Drops a FULL_TEXT index (idempotent — `IF EXISTS`).

# `drop_index!`

```elixir
@spec drop_index!(Arcadic.Conn.t(), String.t(), String.t() | [String.t()]) :: :ok
```

Drops a FULL_TEXT index, raising on error.

# `index_ref`

```elixir
@spec index_ref(String.t(), String.t() | [String.t()]) ::
  {:ok, String.t()} | {:error, :invalid_identifier}
```

Builds the FULL_TEXT index reference `"Type[p1,p2]"`. Accepts one property or a
non-empty list in index order and validates every identifier.

# `search`

```elixir
@spec search(
  Arcadic.Conn.t(),
  String.t(),
  String.t() | [String.t()],
  String.t(),
  keyword()
) ::
  {:ok, [map()]} | {:error, atom() | Exception.t()}
```

Searches a full-text index via `SEARCH_INDEX('Type[property]', :q)` and returns
whole records ranked by relevance. `query` binds as `:q`. Set `:limit` to a
positive integer to cap the result, or set `:with_score` to include the BM25
score in a `"score"` field. Use `:filter` to restrict matches to a list of
`#<bucket>:<pos>` RID strings, bound as `:rids`. An empty list returns no rows.

# `search!`

```elixir
@spec search!(
  Arcadic.Conn.t(),
  String.t(),
  String.t() | [String.t()],
  String.t(),
  keyword()
) :: [map()]
```

Full-text `search`, returning rows or raising.

# `search_fields`

```elixir
@spec search_fields(Arcadic.Conn.t(), String.t(), [String.t()], String.t(), keyword()) ::
  {:ok, [map()]} | {:error, atom() | Exception.t()}
```

Searches FULL_TEXT-indexed fields via `SEARCH_FIELDS(['p1','p2'…], :q)` and returns
whole records. Accepts the same options, including the candidate RID `:filter`, as
`search/5`. Setting `:with_score` projects a constant `score: 0.0` on every row.
Use `search/5` for the BM25 score.

# `search_fields!`

```elixir
@spec search_fields!(
  Arcadic.Conn.t(),
  String.t(),
  [String.t()],
  String.t(),
  keyword()
) :: [map()]
```

Full-text `search_fields`, returning rows or raising.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
