Get list of eye colors via wikidata API - wikidata

For example, I need to get list of eye colors with wikidata API:
https://www.wikidata.org/wiki/Property:P1340
Is it possible to receive names of the colors without SPARQL queries?
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=P1340&languages=en
Thanks in advance.

You need SPARQL at least to get the colors ids (query / json)
Then from the gathered ids you can build the general API query:
https://www.wikidata.org/w/api.php?action=wbgetentities&languages=en&format=json&ids=Q270024|Q2367101|Q17122705|Q16939403|Q1088|Q3133|Q47071|Q23444|Q17122740|Q17122834|Q17244465|Q17244894|Q17122854|Q17126729|Q17291407|Q17245659
or request only the labels:
https://www.wikidata.org/w/api.php?action=wbgetentities&languages=en&format=json&ids=Q270024|Q2367101|Q17122705|Q16939403|Q1088|Q3133|Q47071|Q23444|Q17122740|Q17122834|Q17244465|Q17244894|Q17122854|Q17126729|Q17291407|Q17245659&props=labels

Related

Combining the metrics by request variable in Kibana

Say I need to find 95th and 99th latency of an API with endpoint: "/api/v1/merchant/{merchantId}/logo".
In Kibana I tried searching: "/api/v1/merchant" AND "/logo". But, it returned multiple results, one for each merchantId.
How to search such that single URL is returned which combines the metrics for all merchantIds to give the output?
What you are trying to do is to filter for "api v1 merchant * logo" (mixing wildcards and string query to preserve the order) which is not possible at the moment. But if the filter "api v1 merchant" and logo is correct (aka you don't have APIs like /api/v1/merchant/logo without the id) then there is a solution.
You need a new visualization: just filter for the query and not aggregate the results by API.keyword.

Querying details from GraphDB

We are trying to implement Customer oriented details in Graphdb, were with a single query we can fetch the details of a customer such as his address,phone,email etc. We have build it using had address, has email edges..
g.addV('member').property('id','CU10611972').property('CustomerId', 'CU10611972').property('TIN', 'xxxx').property('EntityType', 'Person').property('pk', 'pk')
g.addV('email').property('id','CU10611972E').property('pk', 'pk')
g.addV('primary').property('id','CU10611972EP').property('EmailPreference','Primary').property('EmailType', 'Home').property('EmailAddress', 'SNEHA#GMAIL.COM').property('pk', 'pk')
g.V('CU10611972').addE('has Email').to(g.V('CU10611972E'))
g.V('CU10611972E').addE('has Primary Email').to(g.V('CU10611972EP')
This is how we have build email relation to the customer.. Similarly we have relations with Address and Phone. So right now we are using this command to fetch the json related to this customer for email,
g.V('CU10611972').out('has Email').out('has Primary Email')
And for complete Customer details we are using union for each Vertex, Phone,Emaiul and address..
Could you please suggest if there is an efficient way to query this detail?
This comes down really to two things.
General graph data modelling
Things the graph DB you are using does and does not support.
With Gremlin there are a few ways to model this data for a single vertex.
If the database supports it, have a list of names like ['home','mobile'] and use metaproperties to attach a phone number to each.
A lot of the Gremlin implementations I am aware of have chosen not to support meta properties. In these cases you have a couple of options.
(a) Have a property for 'Home' and another for 'Mobile'. If either is not known you could either not create that property or give it a value such as "unknown"
(b) Use prefixed strings such as ["Home:123456789","Mobile:123456789] and store them in a set or list (multi properties) and access them in Gremlin using the startingWith predicate. Such as g.V(id).properties('phone').hasValue(startingWith('Mobile')).value()

How to get labels from wikidata?

I want to use wikidata for MultiLabelClassify. I don't understand the struct of wikidata, I want get all the labels from a entity of wikidata. Could you give me some suggestion?
Either use Wikidata Query Service (see link by Kiran) oder use the MediaWiki API.
With the MediaWiki API, you can get all labels of an entity by calling:
https://www.wikidata.org/w/api.php?action=wbgetentities&props=labels&ids=ENTITYID
For example for entity Q42:
https://www.wikidata.org/w/api.php?action=wbgetentities&props=labels&ids=Q42

Places Web Service API, filter by country. Not working

I'm using the Google Places Web Service API to query places serverside as documented here:
https://developers.google.com/places/web-service/autocomplete
According to the docs it should be possible to filter the results by country via parameter 'components=country:SE'.
However when querying like below the filtering doesn't seem to work. The resultset contains both entries from Sweden and other countries.
What am I doing wrong here, any idea?
Example REST query
https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=sto&components=country:SE&key=[YOUR-API-KEY-HERE]
You are running a QueryAutocomplete-request(where the components-parameter isn't available), but the linked documentation is for PlacesAutocomplete-requests.
With a PlacesAutocomplete-request you would get the desired result(limited to sweden )
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=sto&components=country:SE&key=[YOUR-API-KEY-HERE]

How to model Not In query in Couch DB [duplicate]

Folks, I was wondering what is the best way to model document and/or map functions that allows me "Not Equals" queries.
For example, my documents are:
1. { name : 'George' }
2. { name : 'Carlin' }
I want to trigger a query that returns every documents where name not equals 'John'.
Note: I don't have all possible names before hand. So the parameters in query can be any random text like 'John' in my example.
In short: there is no easy solution.
You have four options:
sending a multi range query
filter the view response with a server-side list function
using a CouchDB plugin
use the mango query language
sending a multi range query
You can request the view with two ranges defined by startkey and endkey. You have to choose the range so, that the key John is not requested.
Unfortunately you have to find the commit request that somewhere exists and compile your CouchDB with it. Its not included in the official source.
filter the view response with a server-side list function
Its not recommended but you can use a list function and ignore the row with the key John in your response. Its like you will do it with a JavaScript array.
using a CouchDB plugin
Create an additional index with e.g. couchdb-lucene. The lucene server has such query capabilities.
use the "mango" query language
Its included in the CouchDB 2.0 developer preview. Not ready for production but will be definitely included in the stable release.

Resources