Skip to content

Commit 5bb9919

Browse files
Support service stats (#14)
1 parent c829f3c commit 5bb9919

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using AzureSearchEmulator.Models;
2+
using AzureSearchEmulator.Repositories;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace AzureSearchEmulator.Controllers;
6+
7+
[ApiController]
8+
[Route("servicestats")]
9+
public class ServiceStatsController(ISearchIndexRepository searchIndexRepository) : ControllerBase
10+
{
11+
[HttpGet]
12+
public async Task<IActionResult> Get()
13+
{
14+
var indexes = new List<SearchIndex>();
15+
await foreach (var index in searchIndexRepository.GetAll())
16+
{
17+
indexes.Add(index);
18+
}
19+
20+
var stats = new Dictionary<string, object>
21+
{
22+
["@odata.context"] = $"{Request.Scheme}://{Request.Host}/$metadata#Microsoft.Azure.Search.V2025_05_01_Preview.ServiceStatistics",
23+
["counters"] = new
24+
{
25+
documentCount = new
26+
{
27+
usage = 0,
28+
quota = (long?)null
29+
},
30+
indexesCount = new
31+
{
32+
usage = indexes.Count,
33+
quota = 15
34+
},
35+
indexersCount = new
36+
{
37+
usage = 0,
38+
quota = 15
39+
},
40+
dataSourcesCount = new
41+
{
42+
usage = 0,
43+
quota = 15
44+
},
45+
storageSize = new
46+
{
47+
usage = 0L,
48+
quota = 16106127360L
49+
},
50+
synonymMaps = new
51+
{
52+
usage = 0,
53+
quota = 3
54+
},
55+
skillsetCount = new
56+
{
57+
usage = 0,
58+
quota = 15
59+
},
60+
aliasesCount = new
61+
{
62+
usage = 0,
63+
quota = 30
64+
},
65+
vectorIndexSize = new
66+
{
67+
usage = 0L,
68+
quota = 5368709120L
69+
}
70+
},
71+
["limits"] = new
72+
{
73+
maxStoragePerIndex = 16106127360L,
74+
maxFieldsPerIndex = 1000,
75+
maxFieldNestingDepthPerIndex = 10,
76+
maxComplexCollectionFieldsPerIndex = 40,
77+
maxComplexObjectsInCollectionsPerDocument = 3000
78+
}
79+
};
80+
81+
return Ok(stats);
82+
}
83+
}
84+

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Currently, there is support (to varying degrees) for the following Azure Search
5454
* `search` - The actual search query text to pass to the query parser
5555
* `searchFields` - Comma-delimited list of fields to search
5656
* `searchMode` - The default boolean operator, either `any` (default) or `all`
57+
* Get service stats (mostly dummy values)
58+
* [Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/azureai/azureai-search-document-integration) for example uses servicestats route as a health check endpoint.
5759

5860
Metadata about indexes are stored as JSON files in the `indexes` folder.
5961
Once documents have been added, a subfolder with the index name is created where the Lucene.net index data is stored.

0 commit comments

Comments
 (0)