[ML] Fix sort order of data recognizer module cards (#86250)

* [ML] Fix sort order of data recognizer module cards

* [ML] Add sort by ID to server side recognize endpoint

* [ML] Enhance docs for recognize endpoint success response.
This commit is contained in:
Pete Harverson 2020-12-17 14:11:51 +00:00 committed by GitHub
parent 2106419007
commit b70cabbdcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -29,6 +29,9 @@ export class DataRecognizer extends Component {
// once the mount is complete, call the recognize endpoint to see if the index format is known to us,
ml.recognizeIndex({ indexPatternTitle: this.indexPattern.title })
.then((resp) => {
// Sort results by title prior to display
resp.sort((res1, res2) => res1.title.localeCompare(res2.title));
const results = resp.map((r) => (
<RecognizedResult
key={r.id}

View file

@ -249,6 +249,8 @@ export class DataRecognizer {
})
);
results.sort((res1, res2) => res1.id.localeCompare(res2.id));
return results;
}

View file

@ -133,10 +133,11 @@ export function dataRecognizer({ router, routeGuard }: RouteInitialization) {
* @apiName RecognizeIndex
* @apiDescription By supplying an index pattern, discover if any of the modules are a match for data in that index.
* @apiSchema (params) modulesIndexPatternTitleSchema
* @apiSuccess {object[]} modules Array of objects describing the modules which match the index pattern.
* @apiSuccess {object[]} modules Array of objects describing the modules which match the index pattern, sorted by module ID.
* @apiSuccessExample {json} Success-Response:
* [{
* "id": "nginx_ecs",
* "title": "Nginx access logs",
* "query": {
* "bool": {
* "filter": [