Skip to main content
Version: 0.4.0

검색 API 사용하기

note

💡 검색 API 명세

info
  • 서치 엔진이 구축된 후 검색 결과를 이용하기 위해 사용하는 API 명세입니다.

POST Search 명세

  • Request

    • URL: https://api.invector.co/v0/search/collections

    • Method: POST

    • Headers:

      • Content-Type: application/json
      • Authorization: YOUR_ACCESS_TOKEN
    • Params

      • responseType : "ids" or "documents" default "ids"
    • Body:

      {
      "query": "검색을 위한 쿼리", // 빈 string 전달 시 전체 데이터에 대해 조회 (required)
      "collections": [
      {
      "name": "컬렉션 이름",
      "filters": [
      {
      "field": "필드 이름", // ex) "title"
      "operator": "필터 연산자", // "EQ"
      "value": "필드 값" // ex) "titanic"
      }
      ],
      "sorts": [
      {
      "field": "필드 이름", // ex) "updated_at"
      "order": "정렬 방향" // ex) "ASC"
      }
      ]
      }
      ],
      // 검색 대상 컬렉션 default []이고 빈 리스트시 모든 컬렉션 검색
      "page": 0, // 페이지 번호 default 0
      "size": 20 // 페이지 당 사이즈 default 20
      }
      • 빈 collections를 전달하면 모든 컬렉션에서 검색합니다.
      • 빈 query를 전달하고 filters에 특정 collection을 명시하면 filters만으로 검색합니다.
    • Filters Configuration

      • EQ : equal
      • NE : not equal
      • GT : greater than
      • GTE : greater than or equal
      • LT : less than
      • LTE : less than or equal
      • IN : in
        • Ex.
        {
        "field": "title",
        "operator": "IN",
        "value": ["titanic", "avatar", "inception"]
        }
      • NIN : not in
    • Sorts Configuration

      • ASC : 오름차순 (ascending order)
      • DESC : 내림차순 (descending order)
    • Example Request

      curl -XPOST https://api.invector.co/v0/search/collections \
      -H "Content-Type:: application/json" \
      -H "Authorization: YOUR_ACCESS_TOKEN" \
      -d '{"query":"sample query", "collections":[], page: 0, size: 20}'
  • Response

    • Status Code: 200

    • Body:

      // result type : ids
      {
      "contents": [
      {
      "resource_id": 1,
      "collection_name": "컬렉션 이름"
      },
      {
      "resource_id": 2,
      "collection_name": "컬렉션 이름"
      },
      {
      "resource_id": 3,
      "collection_name": "컬렉션 이름"
      },
      {
      "resource_id": 4,
      "collection_name": "컬렉션 이름"
      },
      {
      "resource_id": 5,
      "collection_name": "컬렉션 이름"
      },
      {
      "resource_id": 6,
      "collection_name": "컬렉션 이름"
      }
      ],
      "hasContent": true,
      "hasNext": true,
      "hasPrev": false,
      "isFirst": true,
      "isLast": false,
      "numberOfElements": 20,
      "page": 0,
      "size": 20,
      "totalElements": 100,
      "totalPages": 5
      }
      // result type : documents
      {
      "contents": [
      {
      "resource_id": 1,
      "collection_name": "컬렉션 이름 1",
      "title": "제목",
      "custom_field1": "사용자 정의 필드",
      ...
      },
      {
      "resource_id": 2,
      "collection_name": "컬렉션 이름 2",
      "title": "제목",
      "custom_field2": "사용자 정의 필드",
      ...
      }
      ],
      "hasContent": true,
      "hasNext": true,
      "hasPrev": false,
      "isFirst": true,
      "isLast": false,
      "numberOfElements": 20,
      "page": 0,
      "size": 20,
      "totalElements": 100,
      "totalPages": 5
      }
      • hasContent : 검색 결과가 있는지 여부
      • hasNext : 다음 페이지가 있는지 여부
      • hasPrev : 이전 페이지가 있는지 여부
      • isFirst : 첫 페이지인지 여부
      • isLast : 마지막 페이지인지 여부
      • numberOfElements : 현재 페이지의 문서 개수
      • page : 현재 페이지 번호
      • size : 요청된 페이지 당 문서 개수
      • totalElements : 전체 문서 개수
      • totalPages : 전체 페이지 수
    • Status Code: 500, 401

    • Body:

      {
      "status": 500, // 401
      "error": "Internal Server Error",
      "message": "Internal Server Error",
      "path": "/v0/search/collections"
      }


Invector 검색 API를 사용하여 강력한 검색 기능을 손쉽게 활용해보세요!