Split search/index API into two separate APIs (#13447)

* Split searcher and indexer API into two separate ones

* Fixed bad merge + fixed namespaces

* Update OpenAPI json scheme
This commit is contained in:
Kenn Jacobsen
2022-11-22 13:43:50 +01:00
committed by GitHub
parent b3555eb374
commit cbd5d45bbf
9 changed files with 284 additions and 273 deletions

View File

@@ -6,15 +6,15 @@ using Umbraco.Cms.ManagementApi.ViewModels.Pagination;
using Umbraco.Cms.ManagementApi.ViewModels.Search;
using Umbraco.Extensions;
namespace Umbraco.Cms.ManagementApi.Controllers.Search;
namespace Umbraco.Cms.ManagementApi.Controllers.Indexer;
[ApiVersion("1.0")]
public class IndexListSearchController : SearchControllerBase
public class AllIndexerController : IndexerControllerBase
{
private readonly IExamineManager _examineManager;
private readonly IIndexViewModelFactory _indexViewModelFactory;
public IndexListSearchController(
public AllIndexerController(
IExamineManager examineManager,
IIndexViewModelFactory indexViewModelFactory)
{
@@ -26,10 +26,10 @@ public class IndexListSearchController : SearchControllerBase
/// Get the details for indexers
/// </summary>
/// <returns></returns>
[HttpGet("index")]
[HttpGet]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(PagedViewModel<IndexViewModel>), StatusCodes.Status200OK)]
public Task<PagedViewModel<IndexViewModel>> Indexes(int skip, int take)
public Task<PagedViewModel<IndexViewModel>> All(int skip, int take)
{
IndexViewModel[] indexes = _examineManager.Indexes
.Select(_indexViewModelFactory.Create)

View File

@@ -4,15 +4,15 @@ using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.ManagementApi.Factories;
using Umbraco.Cms.ManagementApi.ViewModels.Search;
namespace Umbraco.Cms.ManagementApi.Controllers.Search;
namespace Umbraco.Cms.ManagementApi.Controllers.Indexer;
[ApiVersion("1.0")]
public class IndexDetailsSearchController : SearchControllerBase
public class DetailsIndexerController : IndexerControllerBase
{
private readonly IIndexViewModelFactory _indexViewModelFactory;
private readonly IExamineManager _examineManager;
public IndexDetailsSearchController(
public DetailsIndexerController(
IIndexViewModelFactory indexViewModelFactory,
IExamineManager examineManager)
{
@@ -29,11 +29,11 @@ public class IndexDetailsSearchController : SearchControllerBase
/// This is kind of rudimentary since there's no way we can know that the index has rebuilt, we
/// have a listener for the index op complete so we'll just check if that key is no longer there in the runtime cache
/// </remarks>
[HttpGet("index/{indexName}")]
[HttpGet("{indexName}")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(IndexViewModel), StatusCodes.Status200OK)]
public async Task<ActionResult<IndexViewModel?>> Index(string indexName)
public async Task<ActionResult<IndexViewModel?>> Details(string indexName)
{
if (_examineManager.TryGetIndex(indexName, out IIndex? index))
{

View File

@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Umbraco.New.Cms.Web.Common.Routing;
namespace Umbraco.Cms.ManagementApi.Controllers.Indexer;
[ApiController]
[VersionedApiBackOfficeRoute("indexer")]
[ApiExplorerSettings(GroupName = "Indexer")]
public class IndexerControllerBase : ManagementApiControllerBase
{
}

View File

@@ -5,17 +5,17 @@ using Microsoft.Extensions.Logging;
using Umbraco.Cms.Infrastructure.Examine;
using Umbraco.New.Cms.Infrastructure.Services;
namespace Umbraco.Cms.ManagementApi.Controllers.Search;
namespace Umbraco.Cms.ManagementApi.Controllers.Indexer;
[ApiVersion("1.0")]
public class IndexRebuildSearchController : SearchControllerBase
public class RebuildIndexerController : IndexerControllerBase
{
private readonly ILogger<IndexRebuildSearchController> _logger;
private readonly ILogger<RebuildIndexerController> _logger;
private readonly IIndexingRebuilderService _indexingRebuilderService;
private readonly IExamineManager _examineManager;
public IndexRebuildSearchController(
ILogger<IndexRebuildSearchController> logger,
public RebuildIndexerController(
ILogger<RebuildIndexerController> logger,
IIndexingRebuilderService indexingRebuilderService,
IExamineManager examineManager)
{
@@ -29,7 +29,7 @@ public class IndexRebuildSearchController : SearchControllerBase
/// </summary>
/// <param name="indexName"></param>
/// <returns></returns>
[HttpPost("index/{indexName}/rebuild")]
[HttpPost("{indexName}/rebuild")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(OkResult), StatusCodes.Status200OK)]

View File

@@ -1,11 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Umbraco.New.Cms.Web.Common.Routing;
namespace Umbraco.Cms.ManagementApi.Controllers.Search;
[ApiController]
[VersionedApiBackOfficeRoute("search")]
[ApiExplorerSettings(GroupName = "Search")]
public class SearchControllerBase : ManagementApiControllerBase
{
}

View File

@@ -5,23 +5,23 @@ using Umbraco.Cms.ManagementApi.ViewModels.Pagination;
using Umbraco.Cms.ManagementApi.ViewModels.Search;
using Umbraco.Extensions;
namespace Umbraco.Cms.ManagementApi.Controllers.Search;
namespace Umbraco.Cms.ManagementApi.Controllers.Searcher;
[ApiVersion("1.0")]
public class SearcherListSearchController : SearchControllerBase
public class AllSearcherController : SearcherControllerBase
{
private readonly IExamineManager _examineManager;
public SearcherListSearchController(IExamineManager examineManager) => _examineManager = examineManager;
public AllSearcherController(IExamineManager examineManager) => _examineManager = examineManager;
/// <summary>
/// Get the details for searchers
/// </summary>
/// <returns></returns>
[HttpGet("searcher")]
[HttpGet]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(PagedViewModel<SearcherViewModel>), StatusCodes.Status200OK)]
public async Task<ActionResult<PagedViewModel<SearcherViewModel>>> Searchers(int skip, int take)
public async Task<ActionResult<PagedViewModel<SearcherViewModel>>> All(int skip, int take)
{
var searchers = new List<SearcherViewModel>(
_examineManager.RegisteredSearchers.Select(searcher => new SearcherViewModel { Name = searcher.Name })

View File

@@ -8,24 +8,24 @@ using Umbraco.Cms.ManagementApi.ViewModels.Pagination;
using Umbraco.Cms.ManagementApi.ViewModels.Search;
using Umbraco.Extensions;
namespace Umbraco.Cms.ManagementApi.Controllers.Search;
namespace Umbraco.Cms.ManagementApi.Controllers.Searcher;
[ApiVersion("1.0")]
public class SearcherSearchSearchController : SearchControllerBase
public class QuerySearcherController : SearcherControllerBase
{
private readonly IExamineManagerService _examineManagerService;
public SearcherSearchSearchController(IExamineManagerService examineManagerService) => _examineManagerService = examineManagerService;
public QuerySearcherController(IExamineManagerService examineManagerService) => _examineManagerService = examineManagerService;
[HttpGet("searcher/{searcherName}/search")]
[HttpGet("{searcherName}/query")]
[MapToApiVersion("1.0")]
[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)
public async Task<ActionResult<PagedViewModel<SearchResultViewModel>>> Query(string searcherName, string? term, int skip, int take)
{
query = query?.Trim();
term = term?.Trim();
if (query.IsNullOrWhiteSpace())
if (term.IsNullOrWhiteSpace())
{
return new PagedViewModel<SearchResultViewModel>();
}
@@ -50,7 +50,7 @@ public class SearcherSearchSearchController : SearchControllerBase
{
results = searcher
.CreateQuery()
.NativeQuery(query)
.NativeQuery(term)
.Execute(QueryOptions.SkipTake(skip, take));
}
catch (ParseException)

View File

@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Umbraco.New.Cms.Web.Common.Routing;
namespace Umbraco.Cms.ManagementApi.Controllers.Searcher;
[ApiController]
[VersionedApiBackOfficeRoute("searcher")]
[ApiExplorerSettings(GroupName = "Searcher")]
public class SearcherControllerBase : ManagementApiControllerBase
{
}

View File

@@ -892,16 +892,6 @@
}
],
"responses": {
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
@@ -911,6 +901,16 @@
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
@@ -942,16 +942,6 @@
}
],
"responses": {
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
@@ -961,6 +951,16 @@
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
@@ -1181,6 +1181,16 @@
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PagedHelpPage"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
@@ -1190,13 +1200,121 @@
}
}
}
}
}
}
},
"/umbraco/management/api/v1/indexer": {
"get": {
"tags": [
"Indexer"
],
"operationId": "GetIndexer",
"parameters": [
{
"name": "skip",
"in": "query",
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "take",
"in": "query",
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PagedHelpPage"
"$ref": "#/components/schemas/PagedIndex"
}
}
}
}
}
}
},
"/umbraco/management/api/v1/indexer/{indexName}": {
"get": {
"tags": [
"Indexer"
],
"operationId": "GetIndexerByIndexName",
"parameters": [
{
"name": "indexName",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Index"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
},
"/umbraco/management/api/v1/indexer/{indexName}/rebuild": {
"post": {
"tags": [
"Indexer"
],
"operationId": "PostIndexerByIndexNameRebuild",
"parameters": [
{
"name": "indexName",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OkResult"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
@@ -1211,6 +1329,16 @@
],
"operationId": "GetInstallSettings",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InstallSettings"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
@@ -1230,16 +1358,6 @@
}
}
}
},
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InstallSettings"
}
}
}
}
}
}
@@ -1260,6 +1378,9 @@
}
},
"responses": {
"200": {
"description": "Success"
},
"400": {
"description": "Bad Request",
"content": {
@@ -1279,9 +1400,6 @@
}
}
}
},
"200": {
"description": "Success"
}
}
}
@@ -1302,6 +1420,9 @@
}
},
"responses": {
"200": {
"description": "Success"
},
"400": {
"description": "Bad Request",
"content": {
@@ -1311,9 +1432,6 @@
}
}
}
},
"200": {
"description": "Success"
}
}
}
@@ -1374,16 +1492,6 @@
}
],
"responses": {
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NotFoundResult"
}
}
}
},
"200": {
"description": "Success",
"content": {
@@ -1393,6 +1501,16 @@
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NotFoundResult"
}
}
}
}
}
},
@@ -1413,6 +1531,9 @@
}
],
"responses": {
"200": {
"description": "Success"
},
"400": {
"description": "Bad Request",
"content": {
@@ -1432,9 +1553,6 @@
}
}
}
},
"200": {
"description": "Success"
}
}
}
@@ -1455,6 +1573,9 @@
}
},
"responses": {
"201": {
"description": "Created"
},
"400": {
"description": "Bad Request",
"content": {
@@ -1464,9 +1585,6 @@
}
}
}
},
"201": {
"description": "Created"
}
}
}
@@ -1487,15 +1605,8 @@
}
},
"responses": {
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NotFoundResult"
}
}
}
"200": {
"description": "Success"
},
"400": {
"description": "Bad Request",
@@ -1507,8 +1618,15 @@
}
}
},
"200": {
"description": "Success"
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NotFoundResult"
}
}
}
}
}
}
@@ -1688,16 +1806,6 @@
}
],
"responses": {
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
@@ -1707,6 +1815,16 @@
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
@@ -1738,16 +1856,6 @@
}
],
"responses": {
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
@@ -1757,6 +1865,16 @@
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
@@ -2626,130 +2744,12 @@
}
}
},
"/umbraco/management/api/v1/search/index": {
"/umbraco/management/api/v1/searcher": {
"get": {
"tags": [
"Search"
"Searcher"
],
"operationId": "GetSearchIndex",
"parameters": [
{
"name": "skip",
"in": "query",
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "take",
"in": "query",
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PagedIndex"
}
}
}
}
}
}
},
"/umbraco/management/api/v1/search/index/{indexName}": {
"get": {
"tags": [
"Search"
],
"operationId": "GetSearchIndexByIndexName",
"parameters": [
{
"name": "indexName",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Index"
}
}
}
}
}
}
},
"/umbraco/management/api/v1/search/index/{indexName}/rebuild": {
"post": {
"tags": [
"Search"
],
"operationId": "PostSearchIndexByIndexNameRebuild",
"parameters": [
{
"name": "indexName",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OkResult"
}
}
}
}
}
}
},
"/umbraco/management/api/v1/search/searcher": {
"get": {
"tags": [
"Search"
],
"operationId": "GetSearchSearcher",
"operationId": "GetSearcher",
"parameters": [
{
"name": "skip",
@@ -2782,12 +2782,12 @@
}
}
},
"/umbraco/management/api/v1/search/searcher/{searcherName}/search": {
"/umbraco/management/api/v1/searcher/{searcherName}/query": {
"get": {
"tags": [
"Search"
"Searcher"
],
"operationId": "GetSearchSearcherBySearcherNameSearch",
"operationId": "GetSearcherBySearcherNameQuery",
"parameters": [
{
"name": "searcherName",
@@ -2798,7 +2798,7 @@
}
},
{
"name": "query",
"name": "term",
"in": "query",
"schema": {
"type": "string"
@@ -2876,16 +2876,6 @@
],
"operationId": "GetServerStatus",
"responses": {
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
@@ -2895,6 +2885,16 @@
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
@@ -2906,16 +2906,6 @@
],
"operationId": "GetServerVersion",
"responses": {
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"200": {
"description": "Success",
"content": {
@@ -2925,6 +2915,16 @@
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
}
}
@@ -3245,6 +3245,9 @@
}
},
"responses": {
"200": {
"description": "Success"
},
"400": {
"description": "Bad Request",
"content": {
@@ -3254,9 +3257,6 @@
}
}
}
},
"200": {
"description": "Success"
}
}
}
@@ -7115,4 +7115,4 @@
"OAuth": []
}
]
}
}