How can I limit the retrieved results by release date, when I am trying to get a list of books in a time interval?
I have tried with the following query, but it doesn't seem to work (still retrieves books from after 1900:
https://www.googleapis.com/freebase/v1/mqlread?query= [{"type":"/book/book","id":null,"name":null,"/book/written_work/author": [],"/book/written_work/date_of_first_publication>":"1900","/book/book/genre": [],"/book/written_work/subjects":[],"limit":10,"key": {"namespace":"/wikipedia/en_id","value":null}}]&indent=1
Also how do you select that you want the release date returned, when you use the above query?
As user007 mentioned, you've got the sign of your comparison wrong. To get the actual date returned, just ask for it the same way you would normally, by including the property name with no value:
[{"type":"/book/book",
"id":null,
"name":null,
"/book/written_work/author": [],
"/book/written_work/date_of_first_publication<":"1900",
"/book/written_work/date_of_first_publication": null,
"/book/book/genre": [],
"/book/written_work/subjects":[],
"limit":10,
"key": {"namespace":"/wikipedia/en_id","value":null}}]
Note that the date_of_first_publication field is likely to be substantially less well populated than the date of the editions, so you may want to consider changing your query to book who have at least one edition published before 1900.
I've done a substantial amount of work with the Freebase book data, so feel free to message me if you need more help.
date_of_first_publication>":"1900" change to date_of_first_publication<":"1900" so it won't "retrieves books from after 1900"
Related
I am having trouble formatting a date in Gatsby. I have sourced some data from firestore. One of the fields that I have sourced is called datePublished and it contains a number in the form of a timestamp (e.g., 1576945502000). Indeed, it really is a timestamp, but it got saved to firestore in the number format type.
Now, I would like to format the datePublished field using the formatString function in graphql -- as noted here: https://www.gatsbyjs.org/docs/graphql-reference/#dates
But I can't get the formatting to work. Whether I try to format the string in graphiql or on my site, it does not work. Here is the code that I tried:
query MyQuery {
allNewsFeed {
edges {
node {
published(formatString:"dddd Mo, YYYY")
}
}
}
}
And this is the error message that I get in graphiql:
Unknown argument "formatString on field 'datePublished' of type 'NewsFeed'.
If I dig a little deeper, I notice that the field type in firestore is listed as number and in the graphiql document explorer it is listed as a FloatQueryOperatorInput.
What's more, I did a little experiment where I tried to save the same number as a string, number and timestamp in firestore. Neither the string or number format worked and for whatever reason, the gatsby-firesource plugin will not pull in the field with a timestamp format.
So I am wondering, what do I have to do to get this to work in gatsby?
Any ideas?
Thanks.
I had a similar situation with Gatsby not accepting "formatString" on a date field, for me what solved the issue was to change the format of the field to YYYY-MM-DD so it went from 02 06 2017 to 2017-06-02 and gatsby got the hint that that field represents a date.
It seems gatsby "reads" the data and guesses the type and based on that we get certain functionality.
Since gatsby uses moment.js I'm guessing the YYYY-MM-DD format is picked up by it.
I'm using MDX so it was really easy for me to change the format of my date field since it's just plain text, I'm not sure you have the same luxury with firestore but I hope this at least give you some ideas to try out. Good luck!
I wanted to fetch the document which have the particular element attribute value.
So, I tried the cts:element-attribute-value-query but I didn't get any result. But the same element attribute value, I am able to get using cts:element-attribute-range-query.
Here the sample snippet used.
let $s-query := cts:element-attribute-range-query(xs:QName("tit:title"),xs:QName("name"),"=",
"SampleTitle",
("collation=http://marklogic.com/collation/codepoint"))
let $s-query := cts:element-attribute-value-query(xs:QName("tit:title"),xs:QName("name"),
"SampleTitle",
())
return cts:search(fn:doc(),($s-query))
The problem with range-query is it needs the range index. I have hundreds of DB's in multiple hosts. I need to create range indexes on each DB.
What could be the problem with attribute-value-query?
I found the issue with a couple of research.
Actually the result document is a french language document. It has the structure as follows. This is a sample.
<doc xml:lang="fr:CA" xmlns:tit="title">
<tit:title name="SampleTitle"/>
</doc>
The cts:element-attribute-value-query is a language dependent query. To get the french language results, then language needs to be mentioned in the option as follows.
cts:element-attribute-value-query(xs:QName("tit:title"),xs:QName("name"), "SampleTitle",("lang=fr"))
But cts:element-attribute-range-query don't require the language option.
Thanks for the effort.
I want to annotate the corpus using freebase types. But almost every instance in freebase has several types. So I decide to choose the most common types as the instance's type. Is there a way to get the list of the count of the instance? I found this query but it seems not right because the result only has like 400 types. But I think the real types are way more than that.
[{
"id": null,
"name": null,
"type": "/freebase/type_profile",
"/freebase/type_profile/instance_count": []
}]
I question the premise, but let's talk about that at the end after answering your question.
That's (close to) the correct query. When I ask for the count with by adding "return" : "count", I get 17,972 which sounds about right. Perhaps your query framework is adding a "limit" : 400 somehow?
Since you want the most common, why don't we modify the query to sort them. Due to a quirk in the sorting, nulls sort last (or first in our reversed sort), so we'll also add a qualifier to filter them out. We could use >0, but since presumably you aren't interested in low frequency types, let's use >1000 instead.
The final query looks like this:
[{
"id": null,
"name": null,
"type": "/freebase/type_profile",
"instance_count>": 1000,
"instance_count": null,
"sort": "-instance_count"
}]
which will return an ordered list of 849 types sorted in descending order by instance count.
You'll probably want to do a little hand curation of the resulting list to eliminate things like /common/topic, /common/document, /book/isbn, /book/pagination, etc. Mediator types won't also have /common/topic, so you could filter on that first (but depending on the types of things in your corpus, they may all be topics (ie entities) to start with.
Now back to the premise that most frequent == best. Depending on your application, you may actually want more specific (which usually means lower frequency) types, rather than broader, high frequency types. For example, Deceased Person rather than Person, or Politician, Author, or Athlete, in preference to Person. You may want to consider using least frequent type (which is used at least some threshold times). The other thing that you may want to do is blacklist non-commons types (ie types rooted at /base/... or /user/...) which haven't been as carefully curated.
EDIT - word of warning:
Those counts were last updated in 2012. That should be fine for an exercise like this where you just want a rough ordering, but if you need current stats, you'll need to either count occurrences in the Freebase data dump or figure out the separate Stats API which I'm not sure is public/documented http://freebase-site.googlecode.com/svn/trunk/www/lib/queries/stats.sjs
I have a problem that I've been going round and round with in Access 2010. Imagine a table with these columns:
Name Date Time
Now, I have a query that asks the user to input a begin date and an end date and returns all records that are between those two dates. This works fine. However, as soon as I add a sort to the Date column things go awry. Once you put a sort on a column with a parameter the user gets asked to enter the parameter twice. From what I've been able to find out this is normal (although annoying) behavior in Access.
If I add the Date column in a second time and show the column with the sort and don't show the column with the parameter it works fine. The query would look something like:
Name Date (shown & sorted) Date (not shown & parameters) Time
Now when I run the query it all works well and comes out the way I want it to. This would obviously be a great solution then. However, there's another problem. When I save the query, leave, and reopen the query the two columns are merged back into each other. Thus, the change is lost and the user again sees two inputs.
My question is this: what can I do differently to achieve the desired results?
Some possible things I've thought about but don't know the answer to are:
Is there a way to make it so the columns don't merge? Do I have to use a form with the input boxes and take the data from that (I'd prefer not to do that as it will require a lot of additional work to handle the various things I am doing in the database). Is there some obvious thing I'm missing?
Thanks for any suggestions.
FYI: Here is the SQL from the query
SELECT Intentions.Intention, Intentions.MassDate, Intentions.[Time Requested], Intentions.[Place Requested], Intentions.[Offered By], Intentions.Completed
FROM Intentions
WHERE (((Intentions.MassDate) Between [Enter start date] And [Enter end date]))
ORDER BY Intentions.MassDate, Intentions.[Time Requested];
It is true that sometimes the Query Designer in Access will "reorganize" a query when you save it. However, I don't recall an instance where such a reorganization actually broke anything.
For what it's worth, the following query seems to do what you desire. After saving and re-opening it looks and behaves just the same:
For reference, the SQL behind it is
PARAMETERS startDate DateTime, endDate DateTime;
SELECT NameDateTime.Name, NameDateTime.Date, NameDateTime.Time
FROM NameDateTime
WHERE (((NameDateTime.Date) Between [startDate] And [endDate]))
ORDER BY NameDateTime.Date DESC , NameDateTime.Time DESC;
I have had the same problem and I have discovered the reason:
If, after you have run your query, sort a collumn in the result grid and the say yes to save changes to the query the sort action will be stored with the query. This will actually cause the query to run twice. First to create the result and then one more time to sort. You'll therefore be asked twice for the parameters.
SOLUTION: Run the query (entering your parameters twice ;-) ). Then remove the Sorting by clicking on the AZ-eraser symbol in the task bar above (in the sorting compartment).
Then open your query in design-mode and add the sorting order to the appropriate collumn.
Your are then good to go.
Regards
Jan
When my app starts up, I want it to grab the latest changes from Evernote - that is, the changes since it last updated. As part of that process, I want to see what's been moved to the trash recently. Looking at a Note type, it has a created, updated and deleted timestamp.
I went to the NoteStore.findNotesMetadata function, which takes a NoteFilter as an argument. NoteFilter has a NoteSortOrder argument, which is the way in which the notes returned are sorted. NoteSortOrder has the options:
CREATED
UPDATED
RELEVANCE
UPDATE_SEQUENCE_NUMBER
TITLE
There isn't an option to sort notes by date deleted. The date created and modified remain the same as they did before, and so without grabbing the metadata of every note there's ever been, there doesn't seem to be a way for me to see what's been deleted recently.
Any thoughts as to how I could go about sorting by the deleted timestamp?
You will need to get all the metatdata and then sort it. You can use the NotesMetadataResultSpec to limit the amount of data you get. In this case you can set the includeDeleted flag to TRUE, which will only the deleted timestamp of all notes. You can then do another metadata fetch to get the rest of the metadata.
This is not directly related to sort by date deleted. However, I found it to be useful, so I am posting it here.
If you want to control the sort order regardless of when the notes were created or last updates, just put 0., 1., 2., and so on, in front of each note title. That will keep the notes in the order you assign.