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

МетодMethodURLНазначение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

HTTP
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

HTTP
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

shell
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.

МетодMethodURLНазначение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).

shell
dotnet add package Bsa.Search.Core.Rest