"@nguniversal/express-engine": "^8.1.1",
"bootstrap-css-only": "^4.3.1",
"core-js": "^3.3.2",
+ "elastic-builder": "^2.4.0",
"file-saver": "^2.0.2",
"material-design-icons": "^3.0.1",
"moment": "^2.24.0",
CatalogTermContext, FacetFilter} from './search-context';
import {CATALOG_CCVM_FILTERS} from './search-context';
import {HashParams} from '@eg/share/util/hash-params';
-import {ElasticSearchContext} from './elastic-search-context';
@Injectable()
export class CatalogUrlService {
* Creates a new search context from the active route params.
*/
fromUrlParams(params: ParamMap): CatalogSearchContext {
- //const context = new CatalogSearchContext();
- // TODO: hard code for now
- const context = new ElasticSearchContext();
+ const context = new CatalogSearchContext();
this.applyUrlParams(context, params);
let method = 'open-ils.search.biblio.marc';
if (ctx.isStaff) { method += '.staff'; }
- const method = ctx.getApiName();
-
const queryStruct = ctx.compileMarcSearchArgs();
return this.net.request('open-ils.search', method, queryStruct)
termSearch(ctx: CatalogSearchContext): Promise<void> {
+ let method = 'open-ils.search.biblio.multiclass.query';
let fullQuery;
if (ctx.identSearch.isSearchable()) {
} else {
fullQuery = ctx.compileTermSearchQuery();
+ if (ctx.termSearch.groupByMetarecord
+ && !ctx.termSearch.fromMetarecord) {
+ method = 'open-ils.search.metabib.multiclass.query';
+ }
+
if (ctx.termSearch.hasBrowseEntry) {
this.fetchBrowseEntry(ctx);
}
}
- console.debug('search query', JSON.stringify(fullQuery));
+ // TODO XXX TESTING
+ method = 'open-ils.search.elastic.bib_search';
+ fullQuery = ctx.compileElasticSearchQuery();
- let method = ctx.getApiName();
- if (method === null) {
- method = 'open-ils.search.biblio.multiclass.query';
-
- if (ctx.termSearch.groupByMetarecord
- && !ctx.termSearch.fromMetarecord) {
- method = 'open-ils.search.metabib.multiclass.query';
- }
-
- if (ctx.isStaff) {
- method += '.staff';
- }
+ console.debug(`search query: ${fullQuery}`);
+
+ if (ctx.isStaff) {
+ method += '.staff';
}
return new Promise((resolve, reject) => {
newParams(): ElasticSearchParams {
const params = new ElasticSearchParams();
+ /*
params.limit = this.pager.limit;
params.offset = this.pager.offset;
+ */
params.search_org = this.searchOrg.id()
if (this.sort) {
return params;
}
+ /*
getApiName(): string {
// Elastic covers only a subset of available search types.
// Fall back to existing APIs.
return super.getApiName();
}
+ */
}
import {Pager} from '@eg/share/util/pager';
import {ArrayUtil} from '@eg/share/util/array';
+import {RequestBodySearch, MatchQuery} from 'elastic-builder';
+
// CCVM's we care about in a catalog context
// Don't fetch them all because there are a lot.
export const CATALOG_CCVM_FILTERS = [
return query;
}
- compileTermSearchQuery(): any {
+ compileTermSearchQuery(): string {
const ts = this.termSearch;
let str = '';
return str;
}
+ compileElasticSearchQuery(): any {
+ const search = new RequestBodySearch();
+ search.query(new MatchQuery('body', 'hello, ma!'));
+
+ const ts = this.termSearch;
+
+ ts.joinOp.forEach((op, idx) => {
+ let matchOp = 'match';
+
+ switch (ts.matchOp[idx]) {
+ case 'phrase':
+ matchOp = 'match_phrase';
+ break;
+ case 'nocontains':
+ matchOp = 'must_not';
+ break;
+ case 'exact':
+ matchOp = 'term';
+ break;
+ case 'starts':
+ matchOp = 'match_phrase_prefix';
+ break;
+ }
+
+ params.searches.push({
+ field: ts.fieldClass[idx],
+ match_op: matchOp,
+ value: ts.query[idx]
+ });
+
+ });
+
+ console.log(JSON.stringify(search));
+ }
+
// A search context can collect enough data for multiple search
// types to be searchable (e.g. users navigate through parts of a
// search form). Calling this method and providing a search type
break;
}
}
-
- getApiName(): string {
- return null;
- }
}