UNPKG

lemon-core

Version:
105 lines (104 loc) 3.37 kB
import { GeneralItem, Elastic6SimpleQueriable, QueryResult, SimpleSearchParam, AutocompleteSearchParam, SearchBody } from 'lemon-model'; import { Elastic6Service, SearchType } from './elastic6-service'; /** * class: `Elastic6QueryService` * - support simple query like range search. */ export declare class Elastic6QueryService<T extends GeneralItem> implements Elastic6SimpleQueriable<T> { protected readonly service: Elastic6Service; /** * use query w/ the given search-service. * @param service the origin search-service to use. */ constructor(service: Elastic6Service); /** * get options */ protected get options(): import("./elastic6-service").ElasticOption; /** * say hello of identity. */ hello: () => string; /** * query all by id. * * @param id * @param limit * @param isDesc */ queryAll(id: string, limit?: number, isDesc?: boolean): Promise<QueryResult<T>>; /** * search in simple mode * - 기본적으로 'mini-language'를 그대로 지원하도록한다. * - 입력의 파라마터의 키값은 테스트할 필드들이다. * {"stock":">1"} => query_string : "stock:>1" * * - 파라미터 예약: * $query : ES _search 용 쿼리를 그대로 이용. * $exist : 'a,!b,c' => a AND NOT b AND c 를 _exists_ 항목으로 풀어씀. * $source : _source 항목에 포함될 내용. (undefined => _source:false) * $limit : same as "size" * $page : same as "from" / "size" ($limit 를 ipp 으로 함축하여 이용). * * * * [Mini-Language] * ``` * # find title field which contains quick or brown. * title:(quick OR brown) * * # not-null value. * _exists_:title * * # regular exp. * name:/joh?n(ath[oa]n)/ * ``` * * * 참고: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax * 참고: http://okfnlabs.org/blog/2013/07/01/elasticsearch-query-tutorial.html * * @param param search param */ searchSimple(param: SimpleSearchParam): Promise<QueryResult<T>>; /** * search with raw query language. * * @param body SearchBody. * @returns results. */ search(body: SearchBody, searchType?: SearchType): Promise<any>; /** * convert result as `QueryResult` * @param body the query body requested * @param res the result * @returns QueryResult */ asQueryResult(body: SearchBody, res: any): QueryResult<T>; /** * convert `AutocompleteSearchParam` to `SearchBody` * @param param AutocompleteSearchParam * @returns SearchBody */ asSearchBody(param: AutocompleteSearchParam): { field: string; query: string; body: SearchBody; }; /** * search item in Search-as-You-Type way * @param param AutocompleteSearchParam */ searchAutocomplete(param: AutocompleteSearchParam): Promise<{ list: T[]; total?: number; page?: number; limit?: number; aggregations?: any; last?: any; }>; /** * build query parameter from search param. */ buildQueryBody: (param: SimpleSearchParam) => SearchBody; }