IQS UnifiedSearch LiteAdvanced engine

更新时间:
复制 MD 格式

This topic describes the API parameters and usage of UnifiedSearch, also known as Information Query Service (IQS) Unified Search. For an introduction to the LiteAdvanced engine, see LiteAdvanced search engine.

API reference

Request parameters

Parameter

Type

Required

Default

Description

Example

query

string

Yes

-

The search query. The value can be 1 to 1,024 characters in length.

Apple phone

timeRange

string

No

NoLimit

The time range for the query. Valid values:

  • OneDay: Within 1 day

  • OneWeek: Within 1 week

  • OneMonth: Within 1 month

  • OneYear: Within 1 year

  • NoLimit: No limit (default)

NoLimit

category

string

No

null

The search category. If specified, only search results from sites within the specified category are returned. Separate multiple industries with commas. Valid values:

  • finance: finance

  • Law

  • medical: Medical

  • internet: The Internet (curated)

  • tax: Tax

  • news_province: Provincial news

  • news_center: News Center

Note

For general scenarios, do not specify `category` because it can affect retrieval results.

engineType

string

No

LiteAdvanced

The type of search engine. Different engines have different pricing and results. Valid values:

  • LiteAdvanced

LiteAdvanced

contents

mainText

bool

No

false

Specifies whether to return the full body text.

false

markdownText

bool

No

false

Specifies whether to return the body text in Markdown format.

false

summary

bool

No

false

Specifies whether to return an enhanced summary. This is a paid option.

false

rerankScore

bool

No

true

Specifies whether to rerank the search results and return the rerankScore.

true

advancedParams

map<string, string>

No

{}

Advanced search parameters:

  • startPublishedDate: The start of the web page publication time range. The following formats are supported:

    • 2025-07-01

    • 2025-07-01 12:10:00

  • endPublishedDate: The end of the web page publication time range. The format is the same as for startPublishedDate.

  • numResults: The number of results to return. Valid values: 1 to 50.

  • includeSites: The domain names to include. Separate multiple domain names with commas. You can specify up to 100 domain names.

  • excludeSites: The domain names to exclude. Separate multiple domain names with commas. You can specify up to 100 domain names.

{
  "numResults": "10",
  "startPublishedDate": "2025-07-01",
  "endPublishedDate": "2025-07-31"
}

Response parameters

Field

Type

Nullable

Description

Example (Query: What was the most popular brand at the Shanghai Auto Show?)

requestId

string

This field cannot be empty.

The request ID. You can provide this ID for troubleshooting.

35E5608A-A737-2038-384D-D9D34C6BFD9E

pageItems[]

title

string

This field is required.

The website title.

Auto industry leaders gather at the Shanghai Auto Show, AITO becomes the center of attention

link

string

This value cannot be empty.

The website URL.

-

snippet

string

This field is required.

A dynamic summary of the web page, containing parts that match the keywords. The average length is 150 characters.

Note

When engineType is set to LiteAdvanced, the returned snippet is about 500 characters long and contains more information. In this case, you do not need to use the summary field.

-

publishedTime

string

Nullable

The publication time of the web page, in ISO 8601 format.

2025-04-27T20:36:04+08:00

mainText

string

Optional

The full body text parsed from the web page. The maximum length is 3,000 characters, with a retrieval rate of over 98%.

Note

Returned when contents.mainText is enabled.

-

markdownText

string

Optional

The full body text of the web page in Markdown format. This format provides better support for structured information such as tables. The current retrieval rate is about 50% and is continuously improving.

Note

Returned when contents.markdownText is enabled.

-

images

string[]

Nullable

The URLs of images on the web page.

-

hostname

string

Nullable

The name of the website.

China.com

hostLogo

string

Nullable

The logo of the website.

-

summary

string

This can be left empty.

The most relevant information extracted from the full body text of the web page based on the query. This is used to provide an enhanced summary. The default length is about 500 characters.

Note

Returned when contents.summary is enabled.

-

rerankScore

double

Optional

The rerank model is used to reorder the results returned by the engine, which improves relevance.

Note

Returned when contents.rerankScore is enabled. This affects the sorting of results.

0.7786493301391602

websiteAuthorityScore

int32

Optional

The static authority score of the site. This score is determined solely by the website itself. For more information, see Static authority score standards.

2

searchInformation

searchTime

int64

This field is required.

The time taken for the search.

1048

queryContext

engineType

string

Required

The type of search engine.

LiteAdvanced

originalQuery

query

string

This field cannot be empty.

The original request query.

current time in London

timeRange

string

This field is required.

The original request timeRange.

NoLimit

rewrite

enabled

bool

This field cannot be empty.

Indicates whether query rewriting was enabled for this request.

false

timeRange

string

Optional

The rewritten timeRange. This is returned only if the rewritten value is different from the original timeRange.

-

costCredits

search

genericTextSearch

int32

This field is required.

The number of basic text searches. For billing information, see Product billing.

1

liteAdvancedTextSearch

int32

This field cannot be empty.

The number of LiteAdvanced text searches. For billing information, see Product billing.

0

valueAdded

summary

int32

This field cannot be empty.

Value-added package: The number of enhanced summary calls.

1

advanced

int32

The value cannot be empty.

Value-added package: The number of enhanced search calls.

0

Examples

  • Request body

{
  "query": "2025 New Year's Eve Gala Zhou Shen Chyi Yu Huan Yan",
  "engineType": "LiteAdvanced",
  "contents": {
    "mainText": false,
    "markdownText":false,
    "summary": false,
    "rerankScore": true
  },
  "advancedParams": {
    "numResults": "2",
    "startPublishedDate": "2024-12-01",
    "endPublishedDate": "2025-01-31"
  }
}
  • Response parameters

{
  "requestId": "09277650-90de-468e-b299-09048b1c149d",
  "pageItems": [
    {
      "title": "2025 Beijing TV New Year's Eve Gala (2024.12.31) Zhou Shen and Chyi Yu perform 'Huan Yan'",
      "link": "https://m.youku.com/video/id_XNjQ0ODQ5MTk3Mg==.html?source=",
      "snippet": "2025 Beijing TV New Year's Eve Gala (2024.12.31) Zhou Shen and Chyi Yu perform 'Huan Yan' is a high-definition variety show video broadcast on Youku, published at 2025-01-02 22:02:01. Video description: 2025 Beijing TV New Year's Eve Gala (2024.12.31) Zhou Shen and Chyi Yu perform 'Huan Yan'",
      "publishedTime": "2024-12-31T00:00:00+08:00",
      "mainText": null,
      "markdownText": null,
      "images": [
        "https://m.ykimg.com/0542060167769AAC39525FBC7104B9EC"
      ],
      "hostname": "Youku Video",
      "hostLogo": "https://s2.zimgs.cn/ims?kt=url&at=smstruct&key=aHR0cHM6Ly9ndy5hbGljZG4uY29tL0wxLzcyMy8xNTYyODM2MzEzL2ZiL2VmLzkyL2ZiZWY5MmQwNDlhMGViMWZkMWM0MTI0ZjNjMmQzMDAwLmpwZw==&sign=yx:4iAKsNYcDPoZnsM8V51ZWwFQdW0=&tv=400_400",
      "summary": null,
      "rerankScore": 0.9996540546417236,
      "websiteAuthorityScore": 2
    },
    {
      "title": "#ZhouShenChyiYuSingHuanYan#",
      "link": "https://m.weibo.cn/status/P7rt709xu",
      "snippet": "#ZhouShenChyiYuSingHuanYan# No one can escape the 'magic' of Zhou Shen's 'Huan Yan', especially the New Year's Eve version. His voice is like a magnificent painting, slowly unfolding at the turn of the year. Every year, people look forward to his voice for the new year. This time, singing with Chyi Yu will surely add a brilliant stroke to the painting. k Collapse View large image",
      "publishedTime": "2024-12-31T20:18:00+08:00",
      "mainText": null,
      "markdownText": null,
      "images": [],
      "hostname": "Weibo",
      "hostLogo": "https://s2.zimgs.cn/ims?kt=url&at=smstruct&key=aHR0cHM6Ly9ndy5hbGljZG4uY29tL0wxLzcyMy8xNTg0MzMwMjI4LzNkL2RhLzYwLzNkZGE2MDFlY2VlMmI2NGU3ZjAwNzdlMjYzZTA2YTI2Lmljbw==&sign=yx:ODPA0xcJzTX_28mEs3rV87Z1pvw=&tv=400_400",
      "summary": null,
      "rerankScore": 0.9994966983795166,
      "websiteAuthorityScore": 2
    }
  ],
  "sceneItems": [],
  "searchInformation": {
    "searchTime": 774
  },
  "queryContext": {
    "engineType": "LiteAdvanced",
    "originalQuery": {
      "query": "2025 New Year's Eve Gala Zhou Shen Chyi Yu Huan Yan",
      "timeRange": "NoLimit"
    },
    "rewrite": {
      "enabled": false,
      "timeRange": null
    }
  },
  "costCredits": {
    "search": {
      "genericTextSearch": 0,
      "liteAdvancedTextSearch": 1
    },
    "valueAdded": {
      "summary": 0,
      "advanced": 0
    }
  }
}

Error codes

Status

Error code

Error message

Solution

404

InvalidAccessKeyId.NotFound

Specified access key is not found.

Check that your AccessKey ID and AccessKey secret are correct.

403

Retrieval.NotActivate

Please activate AI search service

Place an order or contact your account manager to activate the service.

403

Retrieval.Arrears

Please recharge first.

Your account balance is insufficient. Add funds to your account.

403

Retrieval.NotAuthorised

Please authorize the AliyunIQSFullAccess privilege to the sub-account.

The RAM user is not authorized. For more information, see Create and authorize a RAM user.

403

Retrieval.TestUserPeriodExpired

The test period has expired.

The trial period has expired (valid for 15 days after placing the order). Contact your Alibaba Cloud account manager to upgrade to a paid plan.

429

Retrieval.Throttling.User

Request was denied due to user flow control.

The request rate exceeds the limit. Contact your Alibaba Cloud account manager to upgrade your plan.

429

Retrieval.TestUserQueryPerDayExceeded

The query per day exceed the limit.

The daily query limit for the trial has been exceeded (1,000 queries/day). Contact your Alibaba Cloud account manager to upgrade to a paid plan.

400

Retrieval.InvalidPublishedDate

The specified parameter 'startPublishedDate' has an invalid date format. The correct format should be 'yyyy-MM-dd'.

The format of the start publication date for the advanced search is invalid.

API calls

SDK calls

You can use an Alibaba Cloud AccessKey pair for authentication and an Alibaba Cloud software development kit (SDK) to make API calls.

Python SDK

Prerequisites

Make sure that you have Python 3.8 or later installed.

Install the SDK
pip3 install alibabacloud_iqs20241111==1.6.1
Sample code
  • Synchronous call

import os

from Tea.exceptions import TeaException
from alibabacloud_iqs20241111 import models
from alibabacloud_iqs20241111.client import Client
from alibabacloud_tea_openapi import models as open_api_models


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> Client:
        config = open_api_models.Config(
            # TODO: Replace with your AccessKey ID and AccessKey secret. We recommend loading them from environment variables.
            access_key_id='$YOUR_ACCESS_KEY',
            access_key_secret='$YOUR_ACCESS_SECRET'
        )
        config.endpoint = f'iqs.cn-zhangjiakou.aliyuncs.com'
        return Client(config)

    @staticmethod
    def main() -> None:
        client = Sample.create_client()
        run_instances_request = models.UnifiedSearchRequest(
            body=models.UnifiedSearchInput(
                query='Hangzhou food',
                time_range='NoLimit',
                engine_type='LiteAdvanced',
                contents=models.RequestContents(
                    summary=False,
                    main_text=True,
                ),
                advanced_params=dict(
                    numResults="20",
                    startPublishedDate="2025-01-01"
                )
            )
        )
        try:
            response = client.unified_search(run_instances_request)
            print(
                f"api success, request_id:{response.body.request_id}, size :{len(response.body.page_items)}, server_cost:{response.body.search_information.search_time}")
            if len(response.body.scene_items) > 0:
                print(f"scene_items:{response.body.scene_items[0]}")
            for index, item in enumerate(response.body.page_items):
                print(f"{index}. {'-' * 20}")
                print(f"title:{item.title}")
                print(f"snippet:{item.snippet}")
                print(f"summary:{item.summary}")
                print(f"published_time:{item.published_time}")
                print(f"link:{item.link}")
                print(f"rerank_score:{item.rerank_score}")

        except TeaException as e:
            code = e.code
            request_id = e.data.get("requestId")
            message = e.data.get("message")
            print(f"api exception, requestId:{request_id}, code:{code}, message:{message}")


if __name__ == '__main__':
    Sample.main()
  • Asynchronous call

import asyncio
import os
import time

from Tea.exceptions import TeaException
from alibabacloud_iqs20241111 import models
from alibabacloud_iqs20241111.client import Client
from alibabacloud_tea_openapi import models as open_api_models


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> Client:
        config = open_api_models.Config(
            # TODO: Replace with your AccessKey ID and AccessKey secret. We recommend loading them from environment variables.
            access_key_id=os.environ.get('ACCESS_KEY'),
            access_key_secret=os.environ.get('ACCESS_SECRET')

        )
        config.endpoint = f'iqs.cn-zhangjiakou.aliyuncs.com'
        return Client(config)

    @staticmethod
    async def main_async() -> None:
        start = time.time()
        client = Sample.create_client()
        run_instances_request = models.UnifiedSearchRequest(
            body=models.UnifiedSearchInput(
                query='Hangzhou food',
                time_range='NoLimit',
                contents=models.RequestContents(
                    summary=False,
                    main_text=True,
                )
            )
        )
        try:
            # Use the asynchronous method call
            response = await client.unified_search_async(run_instances_request)
            print(
                f"api success, request_id:{response.body.request_id}, size :{len(response.body.page_items)}, server_cost:{response.body.search_information.search_time}")
            if len(response.body.scene_items) > 0:
                print(f"scene_items:{response.body.scene_items[0]}")
            for index, item in enumerate(response.body.page_items):
                print(f"{index}. {'-' * 20}")
                print(f"title:{item.title}")
                print(f"snippet:{item.snippet}")
                print(f"summary:{item.summary}")
                print(f"published_time:{item.published_time}")
                print(f"link:{item.link}")
                print(f"rerank_score:{item.rerank_score}")
        except TeaException as e:
            code = e.code
            request_id = e.data.get("requestId")
            message = e.data.get("message")
            print(f"api exception, requestId:{request_id}, code:{code}, message:{message}")

if __name__ == '__main__':
    asyncio.run(Sample.main_async())

Java SDK

Prerequisites

Make sure that Java 8 or later is installed.

Maven dependency
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>iqs20241111</artifactId>
    <version>1.6.1</version>
</dependency>
Sample code
package com.aliyun.iqs.example;

import com.aliyun.iqs20241111.Client;
import com.aliyun.iqs20241111.models.*;
import com.aliyun.teaopenapi.models.Config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.HashMap;
import java.util.Map;

public class UnifiedSearchExample {
    public static void main(String[] args) throws Exception {
        Client client = initClient();
        invoke(client, "Hangzhou food", "NoLimit");
    }

    private static Client initClient() throws Exception {
        // TODO: Replace with your AccessKey ID and AccessKey secret. We recommend loading them from environment variables.
        String accessKeyId = "$YOUR_ACCESS_KEY";
        String accessKeySecret = "$YOUR_ACCESS_SECRET";
        
        Config config = new Config()
            .setAccessKeyId(accessKeyId)
            .setAccessKeySecret(accessKeySecret);

        config.setEndpoint("iqs.cn-zhangjiakou.aliyuncs.com");
        return new Client(config);
    }

    private static void invoke(Client client, String query, String timeRange) {
        UnifiedSearchInput input = new UnifiedSearchInput();
        input.setQuery(query);
        input.setTimeRange(timeRange);
        
        // Use the LiteAdvanced engine and advanced search parameters.
        input.setEngineType("LiteAdvanced");
        Map<String, String> advancedParams = new HashMap<>();
        advancedParams.put("numResults", "5");
        advancedParams.put("startPublishedDate", "2025-08-01");
        advancedParams.put("excludeSites", "baidu.com,sina.cn");
        input.setAdvancedParams(advancedParams);

        RequestContents requestContents = new RequestContents().setSummary(false).setMainText(false);
        input.setContents(requestContents);
        UnifiedSearchRequest request = new UnifiedSearchRequest().setBody(input);

        try {
            UnifiedSearchResponse response = client.unifiedSearch(request);
            UnifiedSearchOutput result = response.getBody();

            printOutput(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void printOutput(UnifiedSearchOutput output) {
        // Use GsonBuilder to create a formatted Gson instance.
        Gson gson = new GsonBuilder()
            .setPrettyPrinting()
            .disableHtmlEscaping()
            .create();

        // Print the formatted JSON.
        String prettyJson = gson.toJson(output);
        System.out.println(prettyJson);
    }
}

HTTP calls

You can use an API key from IQS for authentication and make API calls over HTTP. To obtain an API key, see Create and view credentials.

LiteAdvanced

curl  -X POST https://cloud-iqs.aliyuncs.com/search/unified \
--header "Authorization: Bearer $API_KEY" \
--header "Content-Type: application/json" \
--data '{
  "query": "Hangzhou food",
  "engineType": "LiteAdvanced",
  "contents": {
    "mainText": false,
    "markdownText":false,
    "summary": false
  },
  "advancedParams":{
    "numResults": "2",
    "startPublishedDate": "2025-07-01",
    "excludeSites":"aliyun.com,sina.cn"
  }
}'
Important

Replace $API_KEY with the API key created in the IQS console. For more information, see Create and view credentials. It takes about 5 minutes for a new API key to take effect.