REST APIREST API
HTTP-интерфейс Bsa.Search.Api.Host 9.0.47. Базовый адрес — http://<сервер>:2664, интерактивное описание — /swagger/index.html.
Bsa.Search.Api.Host 9.0.47 HTTP interface. Base URL — http://<server>:2664, interactive docs — /swagger/index.html.
МетодыEndpoints
| МетодMethod | URL | НазначениеPurpose |
|---|---|---|
GET | /api/v1/search/version | Версия сервисаService version |
POST | /api/v1/search/indexing | Добавить или обновить документы (индекс создаётся автоматически)Add or update documents (the index is created automatically) |
POST | /api/v1/search | Поиск (полный запрос в JSON)Search (full JSON request) |
GET | /api/v1/search?text=&index=&field=&fields=&count=&offset= | Поиск через параметры URLSearch via URL parameters |
GET | /api/v1/search/short?text=&index= | Поиск, только идентификаторыSearch, ids only |
POST | /api/v1/search/getByIds | Документы по внешним idDocuments by external ids |
POST | /api/v1/search/exists | Какие из id есть в индексеWhich ids exist in the index |
POST | /api/v1/search/delete | Удалить документыDelete documents |
GET | /api/v1/search/parseQuery?text= | Разобрать запрос (дерево в JSON)Parse a query (tree as JSON) |
GET | /api/v1/search/create?index= | Создать индексCreate an index |
GET | /api/v1/search/dropAndCreate?index= | Пересоздать индексRecreate an index |
DELETE | /api/v1/search/drop?name= | Удалить индексDrop an index |
GET | /api/v1/search/isExists?index= | Есть ли индексDoes the index exist |
GET | /api/v1/search/isReady?index= | Готов ли индексIs the index ready |
GET | /api/v1/search/state?index= | Состояние индексаIndex state |
GET | /api/v1/search/info | Состояние всех индексовState of all indexes |
GET | /api/v1/search/flush?index= | Сбросить на дискFlush to disk |
GET | /api/v1/search/close?index= | Закрыть индексClose the index |
GET | /api/v1/search/reindex?index= | ПереиндексироватьReindex |
GET | /api/v1/search/clear | Очистить кэшиClear caches |
Имя индекса со звёздочкой в конце (news_*) в поиске охватывает все индексы с этим префиксом.
An index name ending with an asterisk (news_*) makes a search cover every index with that prefix.
ИндексацияIndexing
POST /api/v1/search/indexing
{
"indexName": "news",
"items": [
{
"id": "doc-1",
"overwrite": true,
"publishTime": "2026-10-14T10:00:00Z",
"fields": [
{ "name": "title", "value": "Bsa.Search 9.0.46" },
{ "name": "content", "value": "Полнотекстовый поиск для .NET" }
]
}
]
}overwrite: true — если документ с таким id уже есть, он заменяется.
overwrite: true — an existing document with the same id is replaced.
ПоискSearch
POST /api/v1/search
{
"indexName": "news",
"query": "(поиск* | search) & title:'Bsa.Search'",
"field": "*",
"count": 20,
"offset": 0,
"fields": ["title"],
"orderField": "RELEVANCE",
"order": "Desc",
"startPublish": "2026-01-01T00:00:00Z"
}| ПолеField | ОписаниеDescription |
|---|---|
query | Запрос на языке запросов (обязательно)Query in the query language (required) |
field | Поле по умолчанию, * — все поля (обязательно)Default field, * — all fields (required) |
count, offset | Размер страницы (по умолчанию 100) и смещениеPage size (default 100) and offset |
fields | Какие поля вернутьWhich fields to return |
orderField, order | Сортировка: RELEVANCE, PUBLISHED, TIMESTAMP; Asc/DescSorting: RELEVANCE, PUBLISHED, TIMESTAMP; Asc/Desc |
startPublish, endPublish, startTimestamp, endTimestamp | Фильтр по датамDate filters |
ids | Ограничить поиск этими внешними idLimit search to these external ids |
isShort | Вернуть только идентификаторыReturn ids only |
totalHitsLimit | Считать совпадения только до этого числа (totalHits — нижняя граница); учитывают сегментные индексыCount matches only up to this number (totalHits is a lower bound); used by segment indexes |
ОтветResponse
| ПолеField | ОписаниеDescription |
|---|---|
totalHits | Всего найденоTotal hits |
documents | Документы страницыDocuments on the page |
isReady, readyIndexes | Все ли индексы готовы и сколько готовоWhether all indexes are ready and how many are |
highlights, terms, score | Подсветка, найденные термы и релевантность по idHighlights, matched terms and relevance by id |
В сегментном формате (по умолчанию) ответ содержит только id, даты и score: fields, highlights и фильтры по фильтрующим полям не работают.
In the segment format (default) the response has only ids, dates and score: fields, highlights and filter-field filters do not work.
Быстрая проверкаQuick check
curl "http://localhost:2664/api/v1/search?index=news&text=поиск*&count=10"Кластерный режимCluster mode
Если включён кластерный режим, распределёнными индексами управляют методы /api/v1/cluster — их можно вызывать на любом узле.
With cluster mode on, distributed indexes are handled by the /api/v1/cluster endpoints — call them on any node.
| МетодMethod | URL | НазначениеPurpose |
|---|---|---|
GET | /api/v1/cluster/state | Состояние узла и кластера (Enabled = false, если режим выключен)Node and cluster state (Enabled = false when the mode is off) |
GET | /api/v1/cluster/nodes | Узлы кластераCluster nodes |
GET | /api/v1/cluster/health | Здоровье: green, yellow, red, disabledHealth: green, yellow, red, disabled |
GET | /api/v1/cluster/metadata | Всё состояние кластера: узлы, голосующие, индексыThe whole cluster state: nodes, voters, indexes |
GET | /api/v1/cluster/routing?index= | Размещение шард индекса по узламShard placement of an index |
POST | /api/v1/cluster/indexes | Создать распределённый индекс { Name, ShardCount?, Replicas? }Create a distributed index { Name, ShardCount?, Replicas? } |
DELETE | /api/v1/cluster/indexes/{name} | Удалить распределённый индексDrop a distributed index |
POST | /api/v1/cluster/indexes/{name}/documents | Добавить или обновить документы { Items: [...] }Add or update documents { Items: [...] } |
POST | /api/v1/cluster/indexes/{name}/documents/delete | Удалить документы { Ids: [...] }Delete documents { Ids: [...] } |
POST | /api/v1/cluster/indexes/{name}/search | Поиск (тело как у POST /api/v1/search)Search (same body as POST /api/v1/search) |
GET | /api/v1/cluster/indexes/{name}/search?text=&field=&fields=&count=&offset= | Поиск через параметры URLSearch via URL parameters |
POST | /api/v1/cluster/indexes/{name}/documents/get | Документы по внешним id { Ids, Fields }Documents by external ids { Ids, Fields } |
POST | /api/v1/cluster/indexes/{name}/shards/{shard}/move | Перенести копию шарда { From, To }Move a shard copy { From, To } |
PUT / DELETE | /api/v1/cluster/voters/{name} | Добавить или убрать голосующий узел (по одному)Add or remove a voting node (one at a time) |
.NET-клиент.NET client
Готовый клиент — Bsa.Search.Core.Rest (.NET Standard 2.0).
A ready client — Bsa.Search.Core.Rest (.NET Standard 2.0).
dotnet add package Bsa.Search.Core.Rest