Mct4041 - Reimplement in-memory search (#4527)

Re-implements the in-memory search index sans Angular

Co-authored-by: Andrew Henry <akhenry@gmail.com>
Co-authored-by: John Hill <john.c.hill@nasa.gov>
Co-authored-by: John Hill <jchill2.spam@gmail.com>
This commit is contained in:
Scott Bell
2021-12-16 01:13:41 +01:00
committed by GitHub
parent e18c7562ae
commit 1f588a2a6e
24 changed files with 627 additions and 2409 deletions

View File

@@ -28,6 +28,7 @@ import EventEmitter from 'EventEmitter';
import InterceptorRegistry from './InterceptorRegistry';
import Transaction from './Transaction';
import ConflictError from './ConflictError';
import InMemorySearchProvider from './InMemorySearchProvider';
/**
* Utilities for loading, saving, and manipulating domain objects.
@@ -41,6 +42,7 @@ function ObjectAPI(typeRegistry, openmct) {
this.eventEmitter = new EventEmitter();
this.providers = {};
this.rootRegistry = new RootRegistry();
this.inMemorySearchProvider = new InMemorySearchProvider(openmct);
this.injectIdentifierService = function () {
this.identifierService = this.openmct.$injector.get("identifierService");
};
@@ -235,7 +237,7 @@ ObjectAPI.prototype.get = function (identifier, abortSignal) {
*
* Object providersSearches and combines results of each object provider search.
* Objects without search provided will have been indexed
* and will be searched using the fallback indexed search.
* and will be searched using the fallback in-memory search.
* Search results are asynchronous and resolve in parallel.
*
* @method search
@@ -250,14 +252,11 @@ ObjectAPI.prototype.search = function (query, abortSignal) {
const searchPromises = Object.values(this.providers)
.filter(provider => provider.search !== undefined)
.map(provider => provider.search(query, abortSignal));
searchPromises.push(this.fallbackProvider.superSecretFallbackSearch(query, abortSignal)
// abortSignal doesn't seem to be used in generic search?
searchPromises.push(this.inMemorySearchProvider.query(query, null)
.then(results => results.hits
.map(hit => {
let domainObject = utils.toNewFormat(hit.object.getModel(), hit.object.getId());
domainObject = this.applyGetInterceptors(domainObject.identifier, domainObject);
return domainObject;
return hit;
})));
return searchPromises;