Google drive api search query with partial match on property value - google-drive-api

I am trying to use Google drive api through files().list().setQ(q).execute() where I have
q = "properties has { key='Code' and value contains 'abc' and visibility='PUBLIC' }"
Is there no option to use "contains" operator for value? I want to do partial matching on the value.
I get the following error (used in java).
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request { "code" : 400, "errors" : [ { "domain" : "global", "location" : "q", "locationType" : "parameter", "message" : "Invalid Value", "reason" : "invalid" } ], "message" : "Invalid Value" }
The exact same query works if I replace "contains" with "=" when there is an exact match.

Related

401-Unauthrized when downloading file for Google Team drive

I am trying to access Team drive files using Drive Picker.
But I am getting this error
{
"code" : 401,
"errors" : [ {
"domain" : "global",
"location" : "Authorization",
"locationType" : "header",
"message" : "Invalid Credentials",
"reason" : "authError"
} ],
"message" : "Invalid Credentials"
}
So I tried to check in Google API Explorer and called the API by passing fileId and supportsTeamDrives = true. But in Google API explorer also, its giving me the same error.
What I am missing here?
Accessing Teamdrives uses a different method. List the files of the particular Teamdrive using the method Teamdrives: list, from there you will be able to get the Teamdrive id from the response just like below:
{
"kind": "drive#teamDrive",
"id": "XXXXXXIDXXXXXXX",
"name": "TheFileName"
}
You can then use the specific file id to get the metadata of a specific file from the method Teamdrives: get.

Google App-Script call functions from service

When accessing functions on google appScript from java code using a service account i get an error of:
Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal error encountered.",
"reason" : "backendError"
} ],
"message" : "Internal error encountered.",
"status" : "INTERNAL"
}
The same this happens from app-engine with default credentials

Mapping definition for [suggest] has unsupported parameters: [payloads : true]

I am using an example right from ElasticSearch documentation here using the Completion Suggestor but I am getting an error saying payloads: true is an unsupported parameter. Which obviously is supported unless the docs are wrong? I have the latest Elasticsearch app install (5.3.0).
Here is my cURL:
curl -X PUT localhost:9200/search/pages/_mapping -d '{
"pages" : {
"properties": {
"title": {
"type" : "string"
},
"suggest" : {
"type" : "completion",
"analyzer" : "simple",
"search_analyzer" : "simple",
"payloads" : true
}
}
}
}';
And the error:
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "Mapping definition for [suggest] has unsupported parameters: [payloads : true]"
}
],
"type" : "mapper_parsing_exception",
"reason" : "Mapping definition for [suggest] has unsupported parameters: [payloads : true]"
},
"status" : 400
}
The payloadparameter has been removed in ElasticSearch 5.3.0 by the following commit: Remove payload option from completion suggester . Here is the comit message:
The payload option was introduced with the new completion
suggester implementation in v5, as a stop gap solution
to return additional metadata with suggestions.
Now we can return associated documents with suggestions
(#19536) through fetch phase using stored field (_source).
The additional fetch phase ensures that we only fetch
the _source for the global top-N suggestions instead of
fetching _source of top results for each shard.

Invalid request error in AWS::Route53::RecordSet when creating stack with AWS CloudFormation json

Invalid request error in AWS::Route53::RecordSet when creating stack with AWS CloudFormation json. Here is the error:
CREATE_FAILED AWS::Route53::RecordSet ApiRecordSet Invalid request
Here is the ApiRecordSet:
"ApiRecordSet" : {
"Type" : "AWS::Route53::RecordSet",
"Properties" : {
"AliasTarget" :{
"DNSName": {"Fn::GetAtt" : ["RestELB", "CanonicalHostedZoneName"]},
"HostedZoneId": {"Fn::GetAtt": ["RestELB", "CanonicalHostedZoneNameID"]}
},
"HostedZoneName" : "some.net.",
"Comment" : "A records for my frontends.",
"Name" : {"Fn::Join": ["", ["api",{"Ref": "Env"},".some.net."]]},
"Type" : "A",
"TTL" : "300"
}
}
What is wrong/invalid in this request?
The only thing I see immediately wrong is that you are using both an AliasTarget and TTL at the same time. You can't do that since the record uses the TTL defined in the AliasTarget. For more info check out the documentation on RecordSet here.
I also got this error and fixed it by removing the "SetIdentifier" field on record sets where it was not needed.
It is only needed when the "Name" and "Type" fields of multiple records are the same.
Documentation on AWS::Route53::RecordSet

How to find a document that contains an apostrophe in the indexable text

I use this line to build a drive query
request.setQ("fullText contains '" + originalFileName + "'");
However when the originalFilename contains a "'" the request throws this error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request { "code" : 400, "errors" : [ {
"domain" : "global",
"location" : "q",
"locationType" : "parameter",
"message" : "Invalid Value",
"reason" : "invalid" } ], "message" : "Invalid Value" }
I understand why the error is thrown, but how do I build a search string to find the files that contain "faq's"in the indexable text? Is there a wildcard character, or an escape character?
You should escape the ' with a \, so:
"fullText contains \'myFile\'"