What is the Freebase query for getting all the SPO triples(subject, predicate, object) created by a user within a span of time? The SPO triples may be deleted or not deleted at the current moment.
For example, I would want to fetch all the SPO triples created by \user\user1 between "2014-01-07" to "2014-01-09".
Related
There is a way to batch get documents after you specified exactly all the file paths using
https://firestore.googleapis.com/v1/projects/projectName/databases/dbName/documents:batchGet.
And there is a way to get all documents and their fields under a collection by sending a GET to https://firestore.googleapis.com/v1/projects/projectName/databases/dbName/documents/collectionName
I ideally want to make a batch request to get document fields for all documents under an array of collections. Is there a way to do this without knowing the document names of every document I intend to get?
Example
I have a structure like projects/projectName/databases/dbName/documents/Inventory/productId/variantId/*location*
Each productId is a document, and under this it has a collection for each variant, and within that collection are documents for each location, that contains a field count.
For a basket, I want to get all inventory counts for all inventory locations, for each productId/variantId in that bas
It is not possible to get all documents based on an array of collection names.
You can use a collection group query and search all collections of a given name, but then you must know the path of each document you want to read.
Alternatively, you can get all documents under a specific path, but then you can't filter by ID anymore, and the collections have to be under a path - not an array.
I have the ID of the DOC, is there any query to search that doc in 2 different collection, am doing this check in my code but is there any firebase query to do same.
If the collections that you want to search have the same name, you can use a collection group query to search both of then (well actually, you'll be searching all collections with that name).
If the collections have different names, there is no way to search them both with a single query. You'll have to do a separate query for each collection, and then merge the results in your application code.
I have some documents in Firestore with two Timestamp fields named lastUpdated and lastProcessed in addition to other fields. lastUpdated field is updated when a user updates the record's fields via web console. lastProcessed field is updated when the backend function processes the document (as a result of user clicking a button).
Following are the possible combinations of these 2 fields.
User has only updated the document, but yet to process (lastUpdated == some_timestamp, lastProcessed == '')
User has updated the document, and then processed (lastUpdated < lastProcessed)
User has updated the document, processed and re-updated (lastUpdated > lastProcessed)
My requirement is to execute a query to get a subset of these records (say top 10), ordered by its most recent timestamp. So when evaluating a record for the ordering, lastUpdated field should be considered for scenarios 1 and 3 above. But lastProcessed field should be considered for scenario 2.
Is this possible with Firestore?
When querying the Firestore database it is not possible to execute the logic you explain in your question (i.e. calculate on the fly the scenario to be applied and define which field shall be used in the query).
One classical solution is to add an extra field to the document which contains the value to be queried for. The value of this field can be calculated (according to the business logic) when you modify the document from your frontend, or via a Cloud Function triggered in the backend each time the doc is changed.
The main advantage of using a Cloud Function is to prevent users modifying the value of this field.
I have a Firestore collection with the following structure:
events > default > participants > participant1
> participant2
> date
etc. So events is a collection, and it has a number of documents with random keys (I've used default as an example). Within "default" there are various fields, but also a subcollection of participants.
When I retrieve events/default I expected to retrieve the list of participants at the same time, but I only get back the fields (date etc) - how do I also get the "participants" collection at the same time?
Firestore queries are shallow and do not consider documents in collections other than the one you are querying. There are no SQL-like "joins" that merge documents from multiple collections.
If you query events, then you will only ever get documents in that collection. If you want participants, you will need to make an additional query, using the full path of the subcollection, including its parent document ID. For example, in JavaScript:
firestore.collection("events").doc(knownId).collection("participants").get()
I'd like to query my database so that it returns Distinct Value of the chosen field. (Like SELECT DICTINCT) in MySQL.
Example: I queried my firstore Collection to get Documents where field messageTo isEqualTo 'Terry', this works fine but returns multiple documents with the same field 'chatID'.
I'd like to query the Collection to return Documents where field messageTo isEqualTo 'Terry' and making 'ChatID' field as DISTINCT value.
Firestore doesn't have anything that's equivalent to "select distinct". You will have to make a decision on the client by looking at the returned documents from a query.
It's worth noting, in a more general sense, that Firestore also does not offer any sort of projection view of documents when using client app APIs. Distinct selection is effectively a projection, because it only returns certain fields. Firestore document fetches and queries always return all the fields in a document.