Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SearcherSearchSearchController : SearchControllerBase

[HttpGet("searcher/{searcherName}/search")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(PagedViewModel<PagedViewModel<SearchResultViewModel>>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(PagedViewModel<SearchResultViewModel>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public async Task<ActionResult<PagedViewModel<SearchResultViewModel>>> GetSearchResults(string searcherName, string? query, int skip, int take)
{
Expand Down
16 changes: 16 additions & 0 deletions src/Umbraco.Cms.ManagementApi/Factories/IndexViewModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ public IndexViewModel Create(IIndex index)

Attempt<string?> isHealthy = indexDiag.IsHealthy();

var properties = new Dictionary<string, object?>();

foreach (var property in indexDiag.Metadata)
{
if (property.Value is null)
{
properties[property.Key] = null;
}
else
{
var propertyType = property.Value.GetType();
properties[property.Key] = propertyType.IsClass && !propertyType.IsArray ? property.Value?.ToString() : property.Value;
}
}

var indexerModel = new IndexViewModel
{
Name = index.Name,
Expand All @@ -45,6 +60,7 @@ public IndexViewModel Create(IIndex index)
SearcherName = index.Searcher.Name,
DocumentCount = indexDiag.GetDocumentCount(),
FieldCount = indexDiag.GetFieldNames().Count(),
ProviderProperties = properties,
};

return indexerModel;
Expand Down
38 changes: 15 additions & 23 deletions src/Umbraco.Cms.ManagementApi/OpenApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PagedPaged"
"$ref": "#/components/schemas/PagedSearchResult"
}
}
}
Expand Down Expand Up @@ -4854,11 +4854,18 @@
"additionalProperties": false
},
"Index": {
"required": [
"canRebuild",
"documentCount",
"fieldCount",
"isHealthy",
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string",
"nullable": true
"minLength": 1,
"type": "string"
},
"healthStatus": {
"type": "string",
Expand All @@ -4882,6 +4889,11 @@
"fieldCount": {
"type": "integer",
"format": "int32"
},
"providerProperties": {
"type": "object",
"additionalProperties": {},
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -5754,26 +5766,6 @@
},
"additionalProperties": false
},
"PagedPaged": {
"required": [
"items",
"total"
],
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64"
},
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PagedSearchResult"
}
}
},
"additionalProperties": false
},
"PagedRecycleBinItem": {
"required": [
"items",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
namespace Umbraco.Cms.ManagementApi.ViewModels.Search;
using System.ComponentModel.DataAnnotations;

namespace Umbraco.Cms.ManagementApi.ViewModels.Search;

public class IndexViewModel
{
[Required]
public string Name { get; init; } = null!;

public string? HealthStatus { get; init; }

[Required]
public bool IsHealthy => HealthStatus == "Healthy";

[Required]
public bool CanRebuild { get; init; }

public string SearcherName { get; init; } = null!;

[Required]
public long DocumentCount { get; init; }

[Required]
public int FieldCount { get; init; }

public IReadOnlyDictionary<string, object?>? ProviderProperties { get; init; }
}