如何在IBM Watson Discovery服务中指定特定文档并提取其关键词?
How to Extract Keywords from a Specific Document in IBM Watson Discovery
Got it, let's sort this out for you. The issue with your current API call is that you're querying the entire collection without narrowing it down to your target document. Here's how to fix that:
Use the filter Parameter to Target a Specific Document
Watson Discovery's Query API lets you filter results using the document_id field. You just need to add a filter parameter to your request that matches the ID of the document you want to analyze.
Modified API Request Example
https://watson-api-explorer.mybluemix.net/discovery/api/v1/environments/{environment_id}/collections/{collection_id}/query?passages=true&count=10&highlight=true&version=2017-11-07&filter=document_id::YOUR_TARGET_DOCUMENT_ID
Key Details to Note:
- Replace
YOUR_TARGET_DOCUMENT_IDwith the actual ID of your document. You can get this ID from the response when you first uploaded the document, or by calling the List Documents API for your collection to retrieve all document IDs. - The
filter=document_id::[ID]syntax tells Discovery to only return results from that single document. - Your existing parameters (
passages=true,count=10,highlight=true) will still work as intended—they'll now focus solely on the document you specified, extracting its top keywords and highlighting relevant passages.
Quick Tip
If you're not sure about the exact document ID, you can first run a query without the filter to get a list of documents (adjust count to a small number if needed), then grab the document_id value from the result set for your target document.
内容的提问来源于stack exchange,提问作者Sanjay Kumar N S
相关产品推荐
相关产品推荐

