Common parameters
Request parameters
Field | Type | Description | Default value |
serviceId | long | The service ID. | 101 |
uq | string | The search value entered by the user. | |
type | string | The search type. Valid values: full-text and segmented. | Dynamic adaptation |
queries | List<map<string, object>> | The search conditions. | [] |
filters | List<map<string, object>> | The filter conditions. | [] |
fields | array | The fields to retrieve (forward index). | [] |
sort | array | The fields to sort by. | [] |
page | int | The page number for paging. | 1 |
rows | int | The number of rows per page for paging. | 10 |
rankModelInfo | map<string, object> | The algorithm intervention configuration (dedicated). | {} |
customConfigInfo | map<string, object> | The custom intervention configuration. | {} |
minScore | double | Filters retrieval results by the minimum relevance score. | |
debug | boolean | The debug information. | 0 |
Response parameters
Field | Type | Description | Default value |
requestId | string | The request ID. | xxxx |
status | int | The status of the request result. | 0 |
message | string | The response message. | |
data.total | int | The total number of search results. | 0 |
data.docs | array(map/dict/json) | The search results. | [] |
debug | map<string, object> | The debug information. |
HTTP calls
Obtain an authentication token
You can obtain an authentication token by calling the PostMSConvSearchTokenGenerated operation in the POP software development kit (SDK). Then, add the "Bearer " prefix to the token and include it in the Authorization header.
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alinlp20200629</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.6.0</version>
</dependency> public static void main(String[] args) throws Exception {
Config config = new Config();
config.setEndpoint("alinlp.cn-beijing.aliyuncs.com");
config.setAccessKeyId("xxxx");
config.setAccessKeySecret("xxxx");
Client client = new Client(config);
PostMSConvSearchTokenGeneratedResponse response = client.postMSConvSearchTokenGenerated();
System.out.println(JacksonUtils.toJson(response));
}{
"body" : {
"code" : 200,
"data" : "OQ25BJFGnMhUJ8NWpATLfcf2VW820vzGbXP5Us/qGdtwn338qSOLwkzyCnbmBD+t7AboAuvYzp5pujlKXfy90KSAnQVVVb/v15w7K+BkozM=",
"httpStatusCode" : 200,
"requestId" : "184B7122-B9EF-14BC-B974-7D013A601FE8",
"success" : true
},
"headers" : {
"access-control-allow-origin" : "*",
"access-control-expose-headers" : "*",
"connection" : "keep-alive",
"content-length" : "217",
"content-type" : "application/json;charset=utf-8",
"date" : "Tue, 02 Jan 2024 07:32:08 GMT",
"etag" : "2khQ+DZUrns9GU5hL39GwUQ7",
"keep-alive" : "timeout=25",
"x-acs-request-id" : "184B7122-B9EF-14BC-B974-7D013A601FE8",
"x-acs-trace-id" : "ec5e93d7765a4df394f82da31c6a729e"
},
"statusCode" : 200
}HTTP requests
Request parameters
Field | Type | Description | Default value |
headers | map/dict/json | The request header information. | {} |
Authorization | string | The authentication information. | Bearer toY1FWrNAjvWkOmp24+UQFIi2PsYzbhNBq+yJmzumNmXw3sro3oOt9Kde5kzLcc4 |
Endpoint
https://nlp.aliyuncs.com
URL
https://nlp.aliyuncs.com/msearch/api/searchEnhance
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Authorization:Bearer OQ25BJFGnMhUJ8NWpATLfcf2VW820vzGbXP5Us/qGdtwn338qSOLwkzyCnbmBD+t7AboAuvYzp5pujlKXfy90KSAnQVVVb/v15w7K+BkozM=" \
-d \
'{
"uq": "ECS console: A web service page with interactive operations",
"type": "title,content,keywords",
"serviceId":23,
"page": 1,
"rows": 5
}' \
'https://nlp.aliyuncs.com/msearch/api/searchEnhance'{
"requestId": null,
"data": {
"total": 3,
"docs": [
{
"_rc_score": 19.05915,
"keywords": "",
"b_id": "25367",
"gmt_modified_origin": "2022-09-26 18:26:12",
"_q_score": 1.0,
"id": 0,
"_id": "0",
"title": "What is Elastic Compute Service (ECS)",
"_score": 19.05915,
"content":"Elastic Compute Service (ECS) is an Infrastructure as a Service (IaaS) level cloud computing service provided by Alibaba Cloud that offers excellent performance, stability, reliability, and scalability."
},
{
"_rc_score": 10.70154,
"keywords": "User Guide",
"b_id": "42431",
"gmt_modified_origin": "2023-01-06 11:07:33",
"_q_score": 0.5614909374237571,
"id": 37,
"_id": "37",
"title": "Configure an accelerated domain name",
"_score": 10.70154,
"content": "ApsaraVideo Media Processing supports distribution acceleration, which speeds up resource access for businesses on specified websites. If you require acceleration, create an accelerated domain name for the website you want to speed up and use it as the origin."
},
{
"_rc_score": 8.819408,
"keywords": "User Guide",
"b_id": "59977",
"gmt_modified_origin": "2023-02-15 09:42:23",
"_q_score": 0.4627387895053032,
"id": 89,
"_id": "89",
"title": "Overview of burstable instances",
"_score": 8.819408,
"content": "A bursted instance is an economy instance type designed for entry-level computing scenarios with burstable performance requirements. This topic describes the features and common scenarios of the burstable instance family. It also explains concepts such as baseline performance, CPU credits, and performance schema, and lists the specific instance types."
}
]
},
"status": 0,
"debug": null,
"message": null
}SDK calls
Java SDK
Maven dependency
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alinlp20200629</artifactId>
<version>2.7.2</version>
</dependency>
<!--Import this dependency if a java.lang.NoSuchMethodError: com.aliyun.credentials.Client.getCredential()Lcom/aliyun/credentials/models/CredentialModel; exception occurs-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>credentials-java</artifactId>
<version>0.3.0</version>
</dependency>Java code sample
public static void main(String[] args) throws Exception {
Config config = new Config();
config.setEndpoint("alinlp.cn-beijing.aliyuncs.com");
config.setAccessKeyId("xxxx");
config.setAccessKeySecret("xxxx");
Client client = new Client(config);
PostMSSearchEnhanceRequest postMSSearchEnhanceRequest = new PostMSSearchEnhanceRequest();
postMSSearchEnhanceRequest.setServiceId(1555L);
postMSSearchEnhanceRequest.setUq("Alibaba Cloud");
postMSSearchEnhanceRequest.setPage(1);
postMSSearchEnhanceRequest.setRows(5);
postMSSearchEnhanceRequest.setFields(Lists.newArrayList("name","title", "content"));
// The runtime parameter timeout setting is valid only for requests that use this runtime parameter instance.
RuntimeOptions runtimeOptions = new RuntimeOptions();
runtimeOptions.connectTimeout = 5000;
runtimeOptions.readTimeout = 10000;
PostMSSearchEnhanceResponse response = client.postMSSearchEnhanceWithOptions(postMSSearchEnhanceRequest, runtimeOptions);
System.out.println(JacksonUtils.toJson(response));
}
Response sample:
{
"body" : {
"code" : 200,
"data" : {
"data" : {
"docs" : [
{
"_id" : "3459649677041723584_2",
"_q_score" : 1,
"_rc_score" : 11.952197,
"_score" : 11.952197,
"content" : " • This document is for reference only for users of Alibaba Cloud products and services. Alibaba Cloud provides this document "as is," "with all faults," and "as available." Alibaba Cloud makes every effort to provide corresponding introductions and operational guidance based on existing technology. However, Alibaba Cloud expressly disclaims all warranties, express or implied, regarding the accuracy, completeness, applicability, and reliability of the content of this document. Alibaba Cloud is not liable for any errors or economic losses incurred by any entity, company, or individual from downloading, using, or trusting this document. Under no circumstances will Alibaba Cloud be liable for any indirect, consequential, exemplary, incidental, special, or punitive damages, including loss of profits, arising from the use of or reliance on this document, even if Alibaba Cloud has been advised of the possibility of such damages. • All content on the Alibaba Cloud website, including but not limited to works, products, images, archives, information, materials, website architecture, website screen arrangements, and web page designs, is legally owned by Alibaba Cloud and/or its affiliates, including but not limited to trademark rights, patent rights, copyrights, and trade secrets. Without the written consent of Alibaba Cloud and/or its affiliates, no one may use, modify, copy, publicly disseminate, alter, distribute, issue, or publicly publish the Alibaba Cloud website, product programs, or content",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : ""
},
{
"_id" : "3459649677041723584_3",
"_q_score" : 0.98918508454972753,
"_rc_score" : 11.822934999999999,
"_score" : 11.822934999999999,
"content" : "Without the written consent of Alibaba Cloud and/or its affiliates, no one may use, modify, copy, publicly disseminate, alter, distribute, issue, or publicly publish the Alibaba Cloud website, product programs, or content. In addition, without the prior written consent of Alibaba Cloud, no one may use, publish, or copy the name of Alibaba Cloud for any marketing, advertising, promotional, or other purposes. This includes, but is not limited to, using "Alibaba Cloud," "Aliyun," "HiChina," and other brands of Alibaba Cloud and/or its affiliates, either alone or in combination. It also includes their affiliated logos and patterns, or any similar company names, trade names, trademarks, product or service names, domain names, graphic marks, logos, identifiers, or descriptions that would enable a third party to identify Alibaba Cloud and/or its affiliates. • If you find any errors in this document, contact Alibaba Cloud.",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : ""
},
{
"_id" : "3459649677041723584_4",
"_q_score" : 0.96916625453880978,
"_rc_score" : 11.583665999999999,
"_score" : 11.583665999999999,
"content" : " Alibaba Cloud OCR Alibaba Cloud OCR/Table of Contents Document Version: 20230509 3 Table of Contents Legal Disclaimer.................................................................................................................................................................................... 2 Table of Contents 3 Foreword 4 Overview................................................................................................................................................................................................................4",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : ""
},
{
"_id" : "3459649677041723584_73",
"_q_score" : 0.96650933715366305,
"_rc_score" : 11.551909999999999,
"_score" : 11.551909999999999,
"content" : "Supports detection and recognition of mixed cards, certificates, and bills within the same file or image. It enables automatic classification, accurate recognition, and structured extraction of key information in scenarios such as mixed financial bills and personal documents. This greatly enhances the technical efficiency of OCR capabilities in financial automation, office automation, and various industry applications. Alibaba Cloud OCR Alibaba Cloud OCR/Product Features Document Version: 20230509 30 Alibaba Cloud OCR Alibaba Cloud OCR/Product Specifications Document Version: 20230509 31 3. Product Specifications",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : "i. Electronic waybill recognition ii. Mixed bill recognition"
},
{
"_id" : "3459649677041723584_42",
"_q_score" : 0.93509536363900292,
"_rc_score" : 11.176444,
"_score" : 11.176444,
"content" : "Accurately recognizes key information in a bank account opening permit, such as the account number, approval number, enterprise name, legal representative's name, and opening bank. Alibaba Cloud OCR Alibaba Cloud OCR/Product Features Document Version: 20230509 15",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : "Bank account opening permit recognition"
}
],
"total" : 108
},
"requestId" : "F861AC34-7F30-15A6-AE92-FD788525036F",
"status" : 0
},
"httpStatusCode" : 200,
"requestId" : "F861AC34-7F30-15A6-AE92-FD788525036F",
"success" : true
},
"headers" : {
"access-control-allow-origin" : "*",
"access-control-expose-headers" : "*",
"connection" : "keep-alive",
"content-type" : "application/json;charset=utf-8",
"date" : "Tue, 02 Jan 2024 07:18:54 GMT",
"keep-alive" : "timeout=25",
"transfer-encoding" : "chunked",
"vary" : "Accept-Encoding",
"x-acs-request-id" : "F861AC34-7F30-15A6-AE92-FD788525036F",
"x-acs-trace-id" : "e6e485a286ccb89ce0008022f62682c9"
},
"statusCode" : 200
}
Python SDK
pip source
pip install alibabacloud_alinlp20200629==2.8.2Python code sample
import json
from alibabacloud_alinlp20200629 import client
from alibabacloud_tea_openapi import models as api_models
from alibabacloud_tea_util.models import RuntimeOptions
from alibabacloud_alinlp20200629 import models
import os
def searchEnhance():
config = api_models.Config(access_key_id=os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
access_key_secret=os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'],
region_id="cn-beijing")
nlp_client = client.Client(config)
request = models.PostMSSearchEnhanceRequest()
request.service_id = 1555
request.uq = 'Alibaba Cloud'
request.page = 1
request.rows = 5
runtime_options = RuntimeOptions(connect_timeout=5000, read_timeout=10000)
response = nlp_client.post_mssearch_enhance_with_options(request, runtime_options)
# For Python 2: print(response)
print(json.dumps(response.body.data, ensure_ascii=False))
{
"data" : {
"docs" : [
{
"_id" : "3459649677041723584_2",
"_q_score" : 1,
"_rc_score" : 11.952197,
"_score" : 11.952197,
"chunkId" : "3459649677041723584_2",
"content" : " • This document is for reference only for users of Alibaba Cloud products and services. Alibaba Cloud provides this document "as is," "with all faults," and "as available." Alibaba Cloud makes every effort to provide corresponding introductions and operational guidance based on existing technology. However, Alibaba Cloud expressly disclaims all warranties, express or implied, regarding the accuracy, completeness, applicability, and reliability of the content of this document. Alibaba Cloud is not liable for any errors or economic losses incurred by any entity, company, or individual from downloading, using, or trusting this document. Under no circumstances will Alibaba Cloud be liable for any indirect, consequential, exemplary, incidental, special, or punitive damages, including loss of profits, arising from the use of or reliance on this document, even if Alibaba Cloud has been advised of the possibility of such damages. • All content on the Alibaba Cloud website, including but not limited to works, products, images, archives, information, materials, website architecture, website screen arrangements, and web page designs, is legally owned by Alibaba Cloud and/or its affiliates, including but not limited to trademark rights, patent rights, copyrights, and trade secrets. Without the written consent of Alibaba Cloud and/or its affiliates, no one may use, modify, copy, publicly disseminate, alter, distribute, issue, or publicly publish the Alibaba Cloud website, product programs, or content",
"docId" : "3459649677041723584",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : "",
"url" : "oss://msearch-cloud-jilin/ossFile1/createDir/OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf"
},
{
"_id" : "3459649677041723584_3",
"_q_score" : 0.98918508454972753,
"_rc_score" : 11.822934999999999,
"_score" : 11.822934999999999,
"chunkId" : "3459649677041723584_3",
"content" : "Without the written consent of Alibaba Cloud and/or its affiliates, no one may use, modify, copy, publicly disseminate, alter, distribute, issue, or publicly publish the Alibaba Cloud website, product programs, or content. In addition, without the prior written consent of Alibaba Cloud, no one may use, publish, or copy the name of Alibaba Cloud for any marketing, advertising, promotional, or other purposes. This includes, but is not limited to, using "Alibaba Cloud," "Aliyun," "HiChina," and other brands of Alibaba Cloud and/or its affiliates, either alone or in combination. It also includes their affiliated logos and patterns, or any similar company names, trade names, trademarks, product or service names, domain names, graphic marks, logos, identifiers, or descriptions that would enable a third party to identify Alibaba Cloud and/or its affiliates. • If you find any errors in this document, contact Alibaba Cloud.",
"docId" : "3459649677041723584",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : "",
"url" : "oss://msearch-cloud-jilin/ossFile1/createDir/OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf"
},
{
"_id" : "3459649677041723584_4",
"_q_score" : 0.96916625453880978,
"_rc_score" : 11.583665999999999,
"_score" : 11.583665999999999,
"chunkId" : "3459649677041723584_4",
"content" : " Alibaba Cloud OCR Alibaba Cloud OCR/Table of Contents Document Version: 20230509 3 Table of Contents Legal Disclaimer.................................................................................................................................................................................... 2 Table of Contents 3 Foreword 4 Overview................................................................................................................................................................................................................4",
"docId" : "3459649677041723584",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : "",
"url" : "oss://msearch-cloud-jilin/ossFile1/createDir/OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf"
},
{
"_id" : "3459649677041723584_73",
"_q_score" : 0.96650933715366305,
"_rc_score" : 11.551909999999999,
"_score" : 11.551909999999999,
"chunkId" : "3459649677041723584_73",
"content" : "Supports detection and recognition of mixed cards, certificates, and bills within the same file or image. It enables automatic classification, accurate recognition, and structured extraction of key information in scenarios such as mixed financial bills and personal documents. This greatly enhances the technical efficiency of OCR capabilities in financial automation, office automation, and various industry applications. Alibaba Cloud OCR Alibaba Cloud OCR/Product Features Document Version: 20230509 30 Alibaba Cloud OCR Alibaba Cloud OCR/Product Specifications Document Version: 20230509 31 3. Product Specifications",
"docId" : "3459649677041723584",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : "i. Electronic waybill recognition ii. Mixed bill recognition",
"url" : "oss://msearch-cloud-jilin/ossFile1/createDir/OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf"
},
{
"_id" : "3459649677041723584_42",
"_q_score" : 0.93509536363900292,
"_rc_score" : 11.176444,
"_score" : 11.176444,
"chunkId" : "3459649677041723584_42",
"content" : "Accurately recognizes key information in a bank account opening permit, such as the account number, approval number, enterprise name, legal representative's name, and opening bank. Alibaba Cloud OCR Alibaba Cloud OCR/Product Features Document Version: 20230509 15",
"docId" : "3459649677041723584",
"name" : "OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf",
"title" : "Bank account opening permit recognition",
"url" : "oss://msearch-cloud-jilin/ossFile1/createDir/OCR Basic Capabilities Product Whitepaper V1.91, for external use.pdf"
}
],
"total" : 108
},
"requestId" : "891CB7AB-5773-132F-B03D-589A3D2A6C7E",
"status" : 0
}