ICE 내부 특정 NodeType에 대한 쿼리를 실행하기 위한 API 유형으로, 다음과 같은 추가적인 항목을 정의한다.

pid

valueType

description

tid

REFERENCE

대상 Node Type

customFilter

STRING

프로그래밍으로 검색 질의를 작성하고 싶은 경우 해당 필터 클래스 설정

query

CHILDREN

ICE내에서 공통으로 사용하는 Lucene 기반의 쿼리를 이용하여 검색 조건을 정의

(apiQuery 에 상세 정의)

apiQuery

pid

valueType

description

methohd

CODE

조회형식, 검색조건

  • "method": "matching"

  • "method": "sorting"

  • "method": "page"

(아래 method 상세 정의)

field

STRING

검색할 대상 nodeType의 propertyType id (pid)

value

STRING

조건값

useCacheKey

BOOLEAN

cacheKey 조합에 사용 여부

useCacheKey

cacheKey조합에 사용 여부를 apiQuery field 단위로 설정할 수 있다.

apiConfig의 "cacheable": true, cacheTime 설정이 되어있어야 useCacheKey 사용 가능하다.

default : true

{
  "typeId": "api",
  "category": "snack",
  "apiId": "list",
  "apiName": "snack List",
  "apiType": "service",
  "method": "GET",
  "parameters": [
  ],
  "statistic": true,
  "aggregation": false,
  "root": {
    "configId": "root",
    "tid": "snack",
    "type": "query",
    "cacheable": true,
    "cacheTime": 60,
    "customResponse": "sampleResponse",
    "query": [
      {
        "method": "matchingShould",
        "field": "id",
        "value": "{{:id}}"
      },
      {
        "method": "matchingShould",
        "field": "name",
        "value": "{{:name}}"
      }
    ],
    "response": [
      {
        "field": "_all_",
        "type": "all"
      }
    ]
  }

{{protocol}}://{{hostname}}:{{port}}/svc/snack/list?_siteId=bestshop&id=104&name=오레오

cacheKey api::snack>list?&id.matchingShould=104&name.matchingShould=오레오

{
    "result": "200",
    "resultMessage": "SUCCESS",
    "totalCount": 2,
    "totalTypeCount": 20,
    "resultCount": 2,
    "items": [
        {
            "id": "104",
            "label": "쿠크다스",
            "name": "쿠크다스",
            "idx": 1
        },
        {
            "id": "103",
            "label": "오레오",
            "name": "오레오",
            "idx": 2
        }
    ]
}

{
  "typeId": "api",
  "category": "snack",
  "apiId": "list",
  "apiName": "snack List",
  "apiType": "service",
  "method": "GET",
  "parameters": [
  ],
  "statistic": true,
  "aggregation": false,
  "root": {
    "configId": "root",
    "tid": "snack",
    "type": "query",
    "cacheable": true,
    "cacheTime": 60,
    "customResponse": "sampleResponse",
    "query": [
      {
        "method": "matchingShould",
        "field": "id",
        "value": "{{:id}}",
        "useCacheKey": false
      },
      {
        "method": "matchingShould",
        "field": "name",
        "value": "{{:name}}"
      }
    ],
    "response": [
      {
        "field": "_all_",
        "type": "all"
      }
    ]
  }
}

{{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=오레오

cacheKey에서 id 제외

[ id=104, name=오레오 ] 로 검색 후 cacheKey에 60초간 캐싱

이후 [ id=105, name=오레오 ] 로 검색하더라도 60초간 응답결과는 변화가 없다.

{
    "result": "200",
    "resultMessage": "SUCCESS",
    "totalCount": 2,
    "totalTypeCount": 20,
    "resultCount": 2,
    "items": [
        {
            "id": "104",
            "label": "쿠크다스",
            "name": "쿠크다스",
            "idx": 1
        },
        {
            "id": "103",
            "label": "오레오",
            "name": "오레오",
            "idx": 2
        }
    ]
}

method

customFilter

apiConfig의 query 조건으로 정의가 힘든 경우 직접 검색 질의를 커스텀 할 수 있다.

apiQuery에 customFilter가 AND로 질의가 추가된다.

커스텀 처리가 필요한 경우 해당 서비스 정의를 해야한다.

아래는 상품 통합 검색 API에 customFilter를 추가하는 사례이다.

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();
}

{
  "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"
        }
      ]
    }
  }