ICE 내부 특정 NodeType에 대한 쿼리를 실행하기 위한 API 유형으로, 다음과 같은 추가적인 항목을 정의한다.
pid | valueType | description |
---|---|---|
tid | REFERENCE | 대상 Node Type |
customFilter | STRING | 프로그래밍으로 검색 질의를 작성하고 싶은 경우 해당 필터 클래스 설정 |
query | CHILDREN | ICE내에서 공통으로 사용하는 Lucene 기반의 쿼리를 이용하여 검색 조건을 정의 (apiQuery 에 상세 정의) |
pid | valueType | description |
---|---|---|
methohd | CODE | 조회형식, 검색조건
(아래 method 상세 정의) |
field | STRING | 검색할 대상 nodeType의 propertyType id (pid) |
value | STRING | 조건값 |
useCacheKey | BOOLEAN | cacheKey 조합에 사용 여부 |
useCacheKey
cacheKey조합에 사용 여부를 apiQuery field 단위로 설정할 수 있다.
apiConfig의 "cacheable": true
, cacheTime
설정이 되어있어야 useCacheKey 사용 가능하다.
default : true
{{protocol}}://{{hostname}}:{{port}}/svc/snack/list?_siteId=bestshop&id=104&name=오레오 cacheKey api::snack>list?&id.matchingShould=104&name.matchingShould=오레오
|
{{protocol}}://{{hostname}}:{{port}}/svc/snack/list?_siteId=bestshop&id=104&name=오레오{{protocol}}://{{hostname}}:{{port}}/svc/snack/list?_siteId=bestshop&id=105&name=오레오 cacheKey api::snack>list?&name.matchingShould=오레오
|
apiConfig의 query 조건으로 정의가 힘든 경우 직접 검색 질의를 커스텀 할 수 있다.
apiQuery에 customFilter가 AND로 질의가 추가된다.
커스텀 처리가 필요한 경우 해당 서비스 정의를 해야한다.
아래는 상품 통합 검색 API에 customFilter를 추가하는 사례이다.
Class 추가
implements QueryFilter
하는 class 를 하나 생성한다.
@Component 어노테이션 추가
@Component("productSearchFilter")
custom 질의 작성
createQuery안에 Lucene에서 제공하는 쿼리로 직접 질의를 작성할 수 있다.
Lucene Query
|
@Override public Query createQuery(QueryContext context) { BooleanQuery.Builder searchQueryBuilder = new BooleanQuery.Builder(); String searchValue = context.getDataStringValue("searchValue"); String reSearchValue = context.getDataStringValue("reSearchValue"); //결과 내 재검색 if ("".equals(searchValue)) { return null; } if (!"".equals(searchValue)) { BooleanQuery.Builder searchValueQueryBuilder = getSearchValueBuilder(searchValue); searchQueryBuilder.add(searchValueQueryBuilder.build(), BooleanClause.Occur.MUST); } return searchQueryBuilder.build(); } |
apiConfig에 customFilter 세팅
@Component 어노테이션 명으로 작성한다.
{ "configId": "root", "tid": "siteProduct", "type": "query", "customFilter": "productSearchFilter", } |
Sample
{ "typeId": "api", "category": "product", "apiId": "search", "apiName": "Product Search List", "apiType": "service", "method": "GET", "parameters": [ { "parameter": "categoryId", "name": "카테고리아이디", "valueType": "STRING", "required": false }, { "parameter": "searchValue", "name": "검색어", "valueType": "STRING", "required": false } ], "statistic": true, "aggregation": false, "root": { "configId": "root", "tid": "siteProduct", "type": "query", "allowParams": false, "orderNo": 1, "cacheable": true, "cacheTime": 60, "customResponse": "productListResponse", "customFilter": "productSearchFilter", "query": [ { "method": "matching", "field": "site", "value": "{{:_siteId}}" }, { "method": "matching", "field": "approvalStatus", "value": "approval" }, { "method": "matching", "field": "saleStatus", "value": "selling" }, { "method": "matching", "field": "exposure", "value": "true" }, { "method": "matching", "field": "deleted", "value": "false" }, { "method": "sorting", "value": "{{:sorting}},id desc" }, { "method": "page", "value": "{{:page}}" }, { "method": "pageSize", "value": "{{:pageSize}}" }, { "method": "matching", "field": "siteCategories", "value": "{{:categoryId}}" } ], "response": [ { "field": "id", "type": "field", "value": "" }, { "field": "name", "type": "field", "value": "" }, { "field": "siteCategories", "type": "field", "value": "" }, { "field": "siteProductSaleInfo", "type": "field", "value": "" }, { "field": "images", "type": "field", "value": "baseProduct.images" }, { "field": "created", "type": "field", "value": "baseProduct.created" } ] } } |