简体   繁体   English

如何查询Watson Discovery API?

[英]how to query watson discovery api?

I am experimenting IBM watsons' Discovery API to get data insights. 我正在尝试IBM Watsons的Discovery API,以获取数据见解。 I want to query using multiple filters. 我想使用多个过滤器进行查询。 I am using python to accomplish the task. 我正在使用python完成任务。 I have tried this for now, but this is not working. 我现在已经尝试过了,但是没有用。

qopts = {'filter':[{'enriched_text.entities.text:Recurrent Neural 
         Networks,Machine Learning classifiers'}]}
my_query = discovery.query(env_id, coll_id, qopts)

with only single entity : 'recurrent Neural Networks' through the discovery UI and through my python query, I get 3 documents from the collection. 通过发现UI和我的python查询,只有一个实体: “递归神经网络” ,我从集合中获得了3个文档。 but with two entities, 'Recurrent Neural Networks,Machine Learning classifiers' , in the UI I get 2 documents but through my code, I get 2 documents. 但是在用户界面中有两个实体“递归神经网络,机器学习分类器” ,我得到了2个文档,但是通过我的代码,我得到了2个文档。

Inside Watson discovery documentation, inside the UI you'll use (according to the documentation): 在Watson发现文档中,您将在UI中使用(根据文档):

在此处输入图片说明

But obviously, without the ! 但显然,没有! operator inside the second text . 第二个text内的运算符。

and I think inside your code you need to use , between the values. 我觉得你的代码中,你需要使用,值之间。

Not sure because I don't use the enriched_text.entities.text inside my filter, just the Strings. 不知道是因为我没有在过滤器中使用enriched_text.entities.text ,而是仅使用字符串。

One possible reference for another example to test: 一个可能的参考来测试另一个示例:

filter=field1:some value,field2:another value

Official reference documentation: here . 官方参考文档: 此处

Below is then right format which works for me. 下面是适合我的正确格式。 with multiple concept and keyword filters, I get a total of 2 search results, which match with the UI query 使用多个概念和关键字过滤器,我总共获得2个搜索结果,这些搜索结果与UI查询匹配

qopts = {'filter':{'enriched_text.concepts.text:"Neural network",enriched_text.keywords.text:"Neural Network",enriched_text.keywords.text:"generative conversational models"'}}

with only entity I get 3 match results 仅实体,我得到3个匹配结果

qopts = {'filter':{'enriched_text.concepts.text:"Neural network"'}}

in this example I am querying the documents with concept 'Neural network' , keywords 'Neural Network' and 'generative conversational models' 在此示例中,我使用概念 “神经网络”, 关键字 “神经网络”和“生成式会话模型”查询文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM