Search documents
    • PDF

    Search documents

    • PDF

    Article summary

    We are preparing a localization service for the content. We will do our best to provide the localization service as soon as possible.

    Searches documents created for each index.

    You need to create a domain and document first to use this operation.

    • You need basic knowledge in search in order to configure a search service.
    • You can perform searches with the Schema set when creating your service.
    • Use queryDSL in JSON.

    POST https://cloudsearch.apigw.ntruss.com/CloudSearch/real/v1/domain/{name}/document/search
    

    Request

    Request Parameters

    ParameterRequiredTypeLimitationsDescription
    nameYstringDomain name

    Overview

    For examples regarding Search Query, refer to How to Use Cloud Search - Search Query Manual.

    {
      "start": (string|int),
    
      "display": (string|int),
    
      "result_format": (string),
    
      "search": {
        "[index_name]": {
          "[query_method]": [{
            "query": (string),
            "name": (string),
            "type": (string),
            "option": (string|bool),
            "ratio": (string|double),
            "term_extractor": (string),
            "stopword": (string)
          }]
        }
      },
    
      "sort": {
        "[sort_target]": (string)
      },
    
      "scope": {
        "[scope_target]": {
          "[scope_method]": (string|int|double|array)
        }
      },
    
      "key_scope": {
        "[scope_method]": (string|array)
      },
    
      "user_scope": (string),
    
      "highlighting": {
        "enable": (string|bool),
        "pre_tag": (string),
        "post_tag": (string),
        "[highlighting_option]": (string|bool)
      },
    
      "display_section": (string|array),
      "passage": {
        "[section_name]": {
           "passage_type": (string),
           "passage_option": (string),
           "max_length": (string)
        },
      },
    
      "aggregate": {
        "[docprop_name]": {
          "max": (string),
          "min": (string),
          "one": (string),
          "sum": (string)
        }
      },
    
      "result_processing": {
        "[section_name]": {
          "remove_duplicate": (string|bool)
        }
      },
    
      "setting": {
        "transfer_timeout": (string|int),
        "search_timeout": (string|int),
        "use_df": (string|bool),
        "reuse_term_extractor": (string|bool),
        "log_level": (string|list),
      }
    }
    

    Request Body

    FieldRequiredTypeLimitationsDescription
    startNString, IntegerDefault: 1Start ranking of search results
    displayNString, IntegerDefault: 20Number of search results
    result_formatNStringJSONSearch result format. Currently, only JSON format is available.
    index_nameYStringSelect one of the indexes previously created.Name of the index to search
    queryListYList<SearchQuery>The SearchQuery for which SearchQuery.query_method is "main" must be included.Search request query
    sortNObjectMap type object which has a sorting order of search results
  • key: Section to sort results by
  • value: Sorting method (desc, asc)
  • scopeNList<SearchScope>List of limited search settings
    key_scopeNObjectMap type object to set limited searches
  • key: Limited search method
  • value: Value that matches the limited search method
  • key option type
  • - exist, nexist: It limits search results to document properties where the specified values exist.
    user_scopeNStringScope expression in the ranking code formThis parameter is used for users to directly specify a scope expression, which is added with the “scope” parameter by using the “and” condition.
  • Example) If you search for documents for which the price is over 2000 and under 5000: "(dp_price > '2000') and (dp_price < '5000')"
  • highlightingNSearchHighlightingDefault: trueSyntax highlighting in search results
    display_sectionNString, ArraySelect sections from those previously created.Specify sections to show as search results. (If it is not specified, data of all sections will be displayed)
    Example: If you want to display the price and name sections only, "price, name"
  • You can combine multiple sections.
    Example: If you want to display the brand and name as one result, "brand+name"
  • passageNList<SearchPassage>Extraction method of search results
    aggregateNList<SearchAggregate>List of aggregate search result settings
    result_processingNSearchResultProcessingPost-processing of search results
    settingNSearchSettingOther preferences for search

    Response

    FieldTypeDescriptionNote
    typestringResponse type
    versionstring
    statusnumberResponse status
    messagestringError messageIt is displayed when the response result is an error.
    time_zonestringTimezone
    elapsed_timenumberTime taken for search
    termobjectQuery contentsObject in which index_name and SearhchQuery are mapped.
    resultobjectSearch result
    result.startnumberStart ranking of search resultsDefault: 1
    result.displaynumberNumber of search resultsDefault: 20
    result.rankingstringRanking method"clous"
    result.sort_bystringSort byDefault: "qds"
    result.total_countnumberTotal number of search results
    result.removed_countnumberNumber of removed search results
    result.item_countnumberNumber of search results
    result.itemsArraySearched documentsList containing request[].content data created when you create a document, and search information
    result.items[]._ranknumberSearch ranking
    result.items[]._keystringDocument’s primary key
    result.items[]._qdsnumberIndicates how well the search query and the document match.

    Response status

    HTTP statusDescription
    200OK (Successfully completed)
    200No collection founded, insert document please
    400Bad Request
    401Unauthorized
    401there is no such service
    403Forbidden
    404Not Found
    500Internal Server Error

    Request Example

    The following example uses the same document as Example of creating a search service.

    Example of general search (search term: "Hyundai")

    POST https://cloudsearch.apigw.ntruss.com/CloudSearch/real/v1/domain/car_dev/document/search
    
    POST /CloudSearch/real/v1/domain/car_dev/document/manage HTTP/1.1
    Host:cloudsearch.apigw.ntruss.com
    accept:application/json
    
    x-ncp-apigw-signature-v2: cDwtHuQeGmwWyNmwlN6XIGA66zge4iMXvfoDQNna05g=
    x-ncp-apigw-timestamp: 1545817618751
    x-ncp-iam-access-key: teGTwtcSEGA7fu28BGGi
    
    {
      "search": {
        "brand_name": {
          "main": {
            "query": "Hyundai"
          }
        }
      }
    }
    

    Example Response

    {
      "version": "1.3.0",
      "status": 200,
      "type": "response",
      "time_zone": "+09:00",
      "elapsed_time": 0.000521,
      "term": {
        "brand_name": {
          "main": {
            "term_count": 1,
            "term_list": [
              "Hyundai"
            ]
          }
        }
      },
      "result": {
        "start": 1,
        "display": 20,
        "ranking": "clous",
        "sort_by": "qds",
        "total_count": 2,
        "removed_count": 0,
        "item_count": 2,
        "items": [
          {
            "_rank": 1,
            "_key": "car-10001",
            "_qds": 0.8729686141014099,
            "brand": "<b>Hyundai</b>",
            "docid": "car-10001",
            "name": "2018 Santa Fe",
            "price": 2815,
            "type": "Medium"
          },
          {
            "_rank": 2,
            "_key": "car-10002",
            "_qds": 0.8729686141014099,
            "brand": "<b>Hyundai</b>",
            "docid": "car-10002",
            "name": "2018 Grandeur",
            "price": 2615,
            "type": "Medium"
          }
        ]
      }
    }
    
    

    Example of stop word search (search term: "Hyundai and Chevrolet")

    Example of stop words (rule name: "josa")

    {
      "type": "filter",
      "word_list": [
        "The", "this", "end", "of", "To", "of", "with"
      ]
    }
    

    The "or" option is needed to search all words that match the search term.

    POST https://cloudsearch.apigw.ntruss.com/CloudSearch/real/v1/domain/car_dev/document/search
    
    POST /CloudSearch/real/v1/domain/car_dev/document/manage HTTP/1.1
    Host:cloudsearch.apigw.ntruss.com
    accept:application/json
    
    x-ncp-apigw-signature-v2: cDwtHuQeGmwWyNmwlN6XIGA66zge4iMXvfoDQNna05g=
    x-ncp-apigw-timestamp: 1545817618751
    x-ncp-iam-access-key: teGTwtcSEGA7fu28BGGi
    
    {
      "search": {
        "brand_name": {
          "main": {
            "query": "Hyundai and Chevrolet",
            "option":"or",
            "stopword":"josa"
          }
        }
      }
    }
    

    Example Response

    {
      "version": "1.3.0",
      "status": 200,
      "type": "response",
      "time_zone": "+09:00",
      "elapsed_time": 0.000517,
      "term": {
        "brand_name": {
          "main": {
            "term_count": 2,
            "term_list": [
              "Chevrolet",
              "Hyundai"
            ]
          }
        }
      },
      "result": {
        "start": 1,
        "display": 20,
        "ranking": "clous",
        "sort_by": "qds",
        "total_count": 3,
        "removed_count": 0,
        "item_count": 3,
        "items": [
          {
            "_rank": 1,
            "_key": "car-10001",
            "_qds": 0.8729686141014099,
            "brand": "<b>Hyundai</b>",
            "docid": "car-10001",
            "name": "2018 Santa Fe",
            "price": 2815,
            "type": "Medium"
          },
          {
            "_rank": 2,
            "_key": "car-10002",
            "_qds": 0.8729686141014099,
            "brand": "<b>Hyundai</b>",
            "docid": "car-10002",
            "name": "2018 Grandeur",
            "price": 2615,
            "type": "Medium"
          },
          {
            "_rank": 3,
            "_key": "car-3",
            "_qds": 0.8707408308982849,
            "brand": "<b>Chevrolet</b>",
            "docid": "car-3",
            "name": "2018 Malibu",
            "price": 2388,
            "type": "Medium"
          }
        ]
      }
    }
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.