简体   繁体   中英

how to query watson discovery api?

I am experimenting IBM watsons' Discovery API to get data insights. I want to query using multiple filters. I am using python to accomplish the task. 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. 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.

Inside Watson discovery documentation, inside the UI you'll use (according to the documentation):

在此处输入图片说明

But obviously, without the ! operator inside the second 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.

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

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

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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