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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user