URL:https://firestore.googleapis.com/v1/{parent=projects//databases//documents}:runQuery
Request body:
{ structuredQuery:
{ from: [
{ collectionId: 'questions'
}
],
orderBy: [
{ field:
{ fieldPath: 'created'
}, direction: 'DESCENDING' }
], select: { fields:
[
{ fieldPath: 'id' },
{ fieldPath: 'details' },
{ fieldPath: 'question' },
{ fieldPath: 'votes' }
]
},
where: {
compositeFilter: {
filters: [
{ fieldFilter: {
field: {
fieldPath: 'author'
},
op: 'EQUAL',
value: {
stringValue: "henry"
}
}
}
], op: 'AND'
}
},
limit: 4
}
}
What error do I get?
[{
"readTime": "2022-12-26T12:46:55.107240Z"
}]
the response isn't returning the expected results
What am I trying to do?
Fetch the given field from the collection: "questions" where the "author" matches "henry"
The documentation is available and it looks pretty straighforward.
Making REST calls
All REST API endpoints exist under the base URL https://firestore.googleapis.com/v1/.
To create a path to a document with the ID LA in the collection
cities under the project YOUR_PROJECT_ID you would use the
following structure.
/projects/YOUR_PROJECT_ID/databases/(default)/documents/cities/LA
To interact with this path, combine it with the base API URL.
https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/cities/LA
The best way to begin experimenting with the REST API is to use
the API Explorer, which automatically generates Google Identity OAuth
2.0 tokens and allows you to examine the API.
Related
I am using Google Calendar API to work with events. For example, someone create an event and invites me. So, at the bottom of the event's detail I have 3 options of "Going": YES/NO/MAYBE. My question is how can I answer this by API?
I tried to use an UPDATE request, but it will create a new version of the event in my own calendar instead.
calendar.events.update(
{
calendarId: "primary",
eventId: event.id,
resource: {
start: {
dateTime: event.start.dateTime,
},
end: {
dateTime: event.end.dateTime,
},
attendees: [
{
email: "myemail#gmail.com",
responseStatus: "accepted",
},
],
},
},
(err, response) => {
}
)
For example, how about using patch instead of update as follows?
Modified script:
calendar.events.patch(
{
calendarId: "primary",
eventId: event.id,
resource: {
attendees: [
{
email: "myemail#gmail.com",
responseStatus: "accepted",
},
],
},
},
(err, response) => {
}
)
Reference:
Events: patch
I want to filter my table data by createdAt,status_invitor and status_invited. I write query Like this
const query = qs.stringify({
filters: {
$and: {
createdAt: { $gte: firstDayOfTheMonth },
createdAt: { $lt: lastDayOfTheMonth },
},
$and: {
status_invitor: statusFilter
},
status_invited: statusFilter,
},
});
but is not working correctly
The filters are combined by default so unless I have misunderstood what you are trying to achieve, you don't need to use the $and operator.
const query = qs.stringify({
filters: {
createdAt: { $gte: firstDayOfTheMonth },
createdAt: { $lt: lastDayOfTheMonth },
status_invitor: statusFilter,
status_invited: statusFilter,
},
});
If you do want to mix AND and OR filters then you need to specify an array. You can see examples of that here: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#complex-filtering
I'm working on a project where I wanted to query more than one field with a search term. This is the code I used to get it working. I think all you need to do is change the $or for the $and and it should work.
const query = qs.stringify( {
filters: {
$or: [
{ name: { $contains: term }},
{ venue: { $contains: term } },
{ performers: { $contains: term } },
{ description: { $contains: term } },
],
},
},
)
I'm currently doing some tests on google datastore, but I'm having a problem with my queries.
If I believe in the documentation https://cloud.google.com/datastore/docs/concepts/queries we can realize a filter on several columns with the instruction EQUALS.
But when testing, I get an error from the API.
While searching on Datastore's github, I found this reference: https://github.com/GoogleCloudPlatform/google-cloud-dotnet/issues/304 which corresponds to my problem, except that for my case the query to the look good.
Here is the request sent:
{
{
"kind": [{
"name": "talk.message"
}],
"filter": {
"compositeFilter": {
"op": "AND",
"filters": [{
"propertyFilter": {
"property": {
"name": "Conversation"
},
"op": "EQUAL",
"value": {
"stringValue": "2f16c14f6939464ea687d316438ad4cb"
}
}
},
{
"propertyFilter": {
"property": {
"name": "CreatedOn"
},
"op": "LESS_THAN_OR_EQUAL",
"value": {
"timestampValue": "2019-03-15T10:43:31.474166300Z"
}
}
},
{
"propertyFilter": {
"property": {
"name": "CreatedOn"
},
"op": "GREATER_THAN_OR_EQUAL",
"value": {
"timestampValue": "2019-03-14T10:43:31.474175100Z"
}
}
}
]
}
}
}
}
And here is the answer from the API:
{Grpc.Core.RpcException: Status(
StatusCode=FailedPrecondition,
Detail="no matching index found. recommended index is:
- kind: talk.message
properties:
- name: Conversation
- name: CreatedOn"
)
According to the documentation, this should be good... but it's not !
What am I missing ?
Your query includes both an EQUALS (on Conversation) and a non-EQUALS filter (on CreatedOn), therefore you need a composite index to fulfil the query. So your query is valid, but it needs a composite index to be able to run the query.
I have been working through the Aikau tutorials on Github but can't work out how to create a list that I can pass on to a view. The requirement is to select all workflow tasks for all users and display the results.
I have added the following widgets which displays the details of one users(hard coded), but I need to cycle through all the users and display all workflows.
model.jsonModel = {
services: [
"alfresco/services/CrudService"
],
widgets:[
{
name: "alfresco/lists/AlfSortablePaginatedList",
config: {
loadDataPublishTopic: "ALF_CRUD_GET_ALL",
loadDataPublishPayload: {
url: "api/task-instances?authority=abeecher"
},
itemsProperty: "data",
widgets: [
{
name: "alfresco/lists/views/AlfListView",
config: {
additionalCssClasses: "bordered",
widgetsForHeader: [
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Workflow ID",
sortable: true,
sortValue: "id"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Description"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Status"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Due Date",
sortable: true,
sortValue: "properties.bpm_dueDate"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Created By"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Assigned To",
sortable: true,
sortValue: "owner.firstName"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Tag1"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Tag2"
}
},
{
name: "alfresco/lists/views/layouts/HeaderCell",
config: {
label: "Tag3"
}
}
],
widgets: [
{
name: "alfresco/lists/views/layouts/Row",
config: {
widgets: [
{
name: "alfresco/lists/views/layouts/Cell",
config: {
additionalCssClasses: "mediumpad",
widgets: [
{
name: "alfresco/renderers/Property",
config: {
propertyToRender: "id",
}
}
]
}
},
{
name: "alfresco/lists/views/layouts/Cell",
config: {
widgets: [
{
name: "alfresco/renderers/Property",
config: {
propertyToRender: "workflowInstance.message",
}
}
]
}
},
{
name: "alfresco/lists/views/layouts/Cell",
config: {
widgets: [
{
name: "alfresco/renderers/Property",
config: {
propertyToRender: "state",
}
}
]
}
},
{
name: "alfresco/lists/views/layouts/Cell",
config: {
widgets: [
{
name: "alfresco/renderers/Property",
config: {
propertyToRender: "properties.bpm_dueDate",
}
}
]
}
},
{
name: "alfresco/lists/views/layouts/Cell",
config: {
widgets: [
{
name: "alfresco/renderers/Property",
config: {
propertyToRender: "workflowInstance.initiator.firstName" ,
}
}
]
}
},
{
name: "alfresco/lists/views/layouts/Cell",
config: {
widgets: [
{
name: "alfresco/renderers/Property",
config: {
propertyToRender: "owner.firstName",
}
}
]
}
},
]
}
}
]
}
}
]
}
}
]
};
The final solution will require the ability to sort the columns and be able to click on a task to see the underlying workflow. What would be the best way to create the initial list based on these requirements?
If I was to write a widget that did the building of the list, how do I couple the widget to the form? Is this a pub/sub solution since the user is not clicking on anything - just loading the page?
I assume that I would need to write custom a webscript if I use the "url" keyword under the loadDataPublishPayload option? If I did write a webscript, what would be the final statement to return the json data to the form?
I just need some guidance on the best way forward.
At the time of writing, using the latest released version of Aikau (1.0.83) it is not possible to do this using out-of-the-box widgets and services.
The main problem is that there is no full mapping between Aikau and the Share XML based forms runtime. This blog post explains the issue at hand. It is however something that we're working on.
Once the "alfresco/services/FormsRuntimeService" is complete this will be an easier exercise to complete. There would be no need to write additional widgets for the lists because the existing list widgets handle all the requirements for sorting/pagination (if the underlying REST API supports sorting and pagination!).
I guess your best way forward is very dependent upon how quickly require this solution. We're making progress with the FormsRuntimeService, but I can't say when it will be fully ready.
The existing pages in Share that show tasks and workflow that do use the Share Forms Runtime rely on APIs that return HTML that is hard-coded to work with the Share YUI2 based widgets - it might be possible to achieve what you want to using the older Surf Component / YUI2 widget approach. That might be one other area to explore.
The main thing to do is to establish whether or not there are existing REST APIs that will meet you core requirements
For a few days my elastica query doesn't work anymore. I don't have problem to populate and if i remove the GeoDistance part the request is been executed and i get results. Currently, in the trace, I got the following message:
"message": "1",
"class": "Elastica\\Exception\\PartialShardFailureException",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/Applications/MAMP/htdocs/GTAB/what2days/api/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php",
"line": 150,
"args": []
}
It means nothing to me so I just made a var_export of $shardsStatistics variable and I get that:
array (
'total' => 6,
'successful' => 5,
'failed' => 1,
'failures' =>
array (
0 =>
array (
'index' => '.marvel-2014.09.16',
'shard' => 0,
'status' => 400,
'reason' => 'SearchParseException[[.marvel-2014.09.16][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"online":{"value":1}}}]}},"filter":{"bool":{"must":[{"geo_distance":{"distance":"100mi","location.latlon":{"lat":48.891773,"lon":2.3379156}}}]}}}}}},"size":"100"}]]]; nested: QueryParsingException[[.marvel-2014.09.16] failed to find geo_point field [location.latlon]]; ',
),
),
)
The error finish by " failed to find geo_point field [location.latlon]] ". I don't know why it doesn't work because when i check the _mapping the geo_point exists and i didn't make a mistake with the name of the property.
location: {
properties: {
latitude: {
type: "float",
store: true
},
latlon: {
type: "geo_point",
store: true,
lat_lon: true
},
longitude: {
type: "float",
store: true
}
}
},
And this is the way i set fos_elastica
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
search:
finder: ~
types:
mytype:
mappings:
title:
type: string
online:
type: integer
information: ~
location:
type: object
properties:
longitude:
type: float
latlon:
type: geo_point
lat_lon: true
boost: 10
persistence:
driver: orm
model: API\Rest\v1\MyBundle\Entity\MyEntity
provider: ~
listener: ~
finder: ~
repository: API\Rest\v1\MyBundle\Repository\MyRepository
When i make a kopf request with the query value (see following query) retrieved by $query->getQuery() i get a correct result.
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"term": {
"online": {
"value": 1
}
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"geo_distance": {
"distance": "1mi",
"location.latlon": {
"lat": 48.891773,
"lon": 2.3379156
}
}
}
]
}
}
}
}
}
I don't know what to do. I was on 3.0.*#alpha version and now I'm trying the dev-master. I hope someone will help me find what goes wrong.
When I make a var_export in the method getData from Elastica/Response.php I have the failure I explained earlier and I also have 1 hit (the one Iwant to get).
I finally found the solution.
I had to add an index_name and tell \Elastica\Search to addIndex('new_index') and addType('specific type')
I thought the search will automatically get the correct index because I was using a specific repository but I was wrong.