I am trying to use the freebase search API to obtain the parties of specific politicians as well as general biographical data (using php). I know that the search api passes the id of each search result found to an MQL query specified by the mql_output parameter.
Here is the MQL query I have at the moment which I use for the mql_ouput parameter
{
"name":null,
"/people/person/date_of_birth":null,
"/people/person/gender":null,
"/wikipedia/topic/en_id":null,
"id":null,
"/government/politician/party":[
{
party : null
}
]
}
and this is the resultant query url
https://www.googleapis.com/freebase/v1/search?Barrack%20Obama&filter=%28all%20type%3Apolitician%29&mql_output=%7B%22name%22%3Anull%2C%22%5C%2Fpeople%5C%2Fperson%5C%2Fdate_of_birth%22%3Anull%2C%22%5C%2Fpeople%5C%2Fperson%5C%2Fgender%22%3Anull%2C%22%5C%2Fwikipedia%5C%2Ftopic%5C%2Fen_id%22%3Anull%2C%22id%22%3Anull%2C%22%5C%2Fgovernment%5C%2Fpolitician%5C%2Fparty%22%3A%5B%7B%7D%5D%7D&key=AIzaSyDdJ_9L6mcWXinx5Lehku2TULmJhOMESew&indent=true
Thanks for your help, sorry that it's quite basic question,
Mark
Answer
Could not self answer due to not enough forum rep.
I just realised what I needed to do after going over some more examples. To have the database retrieve the party information I needed to use the following query.
{
"name":null,
"/people/person/date_of_birth":null,
"/people/person/gender":null,
"/wikipedia/topic/en_id":null,
"id":null,
"/government/politician/party":{
"party" : null
}
}
Mark
I just realised what I needed to do after going over some more examples. To have the database retrieve the party information I needed to use the following query.
{ "name":null, "/people/person/date_of_birth":null, "/people/person/gender":null, "/wikipedia/topic/en_id":null, "id":null, "/government/politician/party":{ "party" : null } }
Mark
Related
We are using Weaviate to serve e-commerce results.
Our Weaviate database stores all the products we sell.
Based on the customer and the search term we create a vector and use this to query the database. This property is called search_engine_query_vector.
For example if a customer has a habit of buying expensive products and searches for "TV" the system will most likely create a vector which is "closer" to the more expensive TVs in the database. So their first page of results is the most expensive TVs.
While this works well 99% of the time we also want ppl to be able to sort based on price.
For this we will send a query to Weaviate, where we only return products which are close to our vector(It is assumed this is all the TVs). like below:
client.query.get("Product", ["sku", "responseBody", "_additional { certainty }",
"stores { ...on Store {storeId salesPrice additionalResponseBody}}"]).with_near_vector(
{"vector": search_engine_query_vector, "similarity": TV_CUTOFF})
.limit(10)
.sort_base_on_price()
My question is there functionality in the api analogous to sort_base_on_price?
you can assume price is a number field in the schema.
Great to hear you're working with Weaviate for an e-commerce solution.
Weaviate added an initial version of sorting functionality in version 1.13!
With the Weaviate version 1.13.0 we also released the python-client v3.5.0 that introduced this functionality too. You can find the needed method documentation for python here or for other clients here!
For your use case, you could also try the following GraphQL query in the Weaviate Console:
{
Get {
Product(nearVector :{
vector:[search_engine_query_vector],
certainty: TV_CUTOFF
}
sort:{
order:desc,
path:["price_field"]
}
limit: 10
) {
sku
responseBody
stores { ...on Store {
storeId
salesPrice
additionalResponseBody
}
_additional {
certainty
}
}
}
}
I am trying to check that a new Post received, contains the string corresponding to a specific email
(contained in auth.token.email, let us say toto#tata.com. We used google-sign and that user is authenticated)
The regular expression below is mainly searching for the string "auth.token.email" which is not what we need.
It should search for toto#tata.com
{
"rules":
{
"Posts":
{
".validate" : "newData.val().matches(/auth.token.email/)"
}
}
}
The syntax above must miss something, but I could not find it on internet so far
thanks
Additional note:
I tried also this rule below, but it does not work too (return FALSE)
".validate" : "newData.val().contains(auth.token.email)"
it seems this is not feasible (I do not need to implement it anymore) as not many (no one) would want to implement that model
Using SoQL (Socrata Query Language) we can filter the values of a data set using the in(...) function.
A sample example is shown in the socrata website using the Chicago open data portal.
https://data.cityofchicago.org/resource/6zsd-86xi.json?$where=primary_type in('THEFT', 'ROBBERY', 'INTIMIDATION')
But when I try this functionality using a different data set of the same data portal I don't get the answer. Here is the SoQL I used
https://data.cityofchicago.org/resource/uupf-x98q.json?$where=police_district in('12','24')
I get the following error.
{
"code" : "query.compiler.malformed",
"error" : true,
"message" : "Error, could not parse SoQL query \"select * from #uupf-x98q where police_district in('12','24')\"",
"data" : {
"query" : "select * from #uupf-x98q where police_district in('12','24')"
}
}
In the case of your second query, you're accessing it via a filtered view which limits some of the things you can do with that API endpoint. If you follow the link to the API Documentation for that dataset ("Export" -> "SODA API" -> "API Docs") it'll bring you to the dataset-level API docs where you'll have more success.
For the first query, I'd recommend you migrate to it's new API endpoint, where you'll find performance to be a lot better. It should be as simple as swapping out the dataset identifier or base URL in your query.
Tryng to get a simple result using "Where" style in firebase but get null althe time, anyone can help with that?
http://jsfiddle.net/vQEmt/68/
new Firebase("https://examples-sql-queries.firebaseio.com/messages")
.startAt('Inigo Montoya')
.endAt('Inigo Montoya')
.once('value', show);
function show(snap) {
$('pre').text(JSON.stringify(snap.val(), null, 2));
}
Looking at the applicable records, I see that the .priority is set to the timestamp, not the username.
Thus, you can't startAt/endAt the user's name as you've attempted here. Those are only applicable to the .priority field. These capabilities will be expanding significantly over the next year, as enhancements to the Firebase API continue to roll out.
For now, your best option for arbitrary search of fields is use a search engine. It's wicked-easy to spin one up and have the full power of a search engine at your fingertips, rather than mucking with glacial SQL-esque queries. It looks like you've already stumbled on the appropriate blog posts for that topic.
You can, of course, use an index which lists users by name and stores the keys of all their post ids. And, considering this is a very small data set--less than 100k--could even just grab the whole thing and search it on the client (larger data sets could use endAt/startAt/limit to grab a recent subset of messages):
new Firebase("https://examples-sql-queries.firebaseio.com/messages").once('value', function(snapshot) {
var messages = [];
snapshot.forEach(function(ss) {
if( ss.val().name === "Inigo Montoya" ) {
messages.push(ss.val());
}
});
console.log(messages);
});
Also see: Database-style queries with Firebase
I seem to be having problem pulling out the text content of the following query without making another call:
http://tinyurl.com/mgsewz2 via the mqlread api
{
"id": "/en/alcatraz_island",
"/common/topic/description": [{}],
"/common/topic/topic_equivalent_webpage": [],
"/common/topic/official_website": null
}
I can't retrieve the following
description
equivalent webpage (I'm looking for the en wiki page)
, but I can obtain the official_website url.
It looks like I can get it via the search api via output= but I can't walk through the entire set that I'm looking for without getting search request is too large error.
http://markmail.org/message/hd6pcveta7bhuz25#query:+page:1+mid:u7xegxlhtmhwiqbl+state:results
Thanks!
It you want to download large subsets of Freebase data, your best bet is to use the Freebase RDF Dumps. They contain all the properties that you listed above.