How to use projection with GAE? - google-app-engine

I have the following code:
employees = Employee.all()
employees.projection('first_name')
employees.filter('passport_id =', passport_id)
employees.order('-added')
results = employees.fetch(5)
Second line is not allowed:
AttributeError: 'Query' object has no attribute 'projection'
Another approach also returns the error:
employees = db.Query(Employee, projection=('first_name'))
TypeError: __init__() got an unexpected keyword argument 'projection'
But if I read the doc correctly, it should be supported.

Which version of AppEngine SDK are you running? projection queries were added in version 1.6.5

Related

solr 8.11 Field Types docs contradiction. Any guidance?

I'm setting up my first Solr server via docker using solr:8.11.1-slim. I am gonna use the schema API to set up the schema for my core whose name is 'products'.
While reading the docs there seems to be false info on the docs for field types:
https://solr.apache.org/guide/8_11/field-types-included-with-solr.html
vs.
https://solr.apache.org/guide/8_11/schema-api.html
I followed the first guide to get info on what field types I can specify and am trying to send requests based on the second doc such as this:
{ 'add-field': { "name":"latlong", "type":"LatLongPointSpatialField", "multiValued":False, "stored":True, 'indexed': True } },
but Solr gives me back errors such as:
org.apache.solr.api.ApiBag$ExceptionWithErrObject: error processing commands, errors: [{add-field={name=latlong, type=LatLongPointSpatialField, multiValued=false, stored=true, indexed=true}, errorMessages=[Field 'latlong': Field type 'LatLongPointSpatialField' not found
So what gives? Am I misreading the docs or are they wrong or is something wrong with the solr 8.11.1 image in docker? Why does it not accept the field types I'm providing?
Thanks for your help ahead of time.

How can I stop Google App Engine(GAE) from CloudFunctions

I'd like to stop GAE instance from CloudFunctions(node.js 8)
I refered to the following documents.
https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1beta5/apps.services.versions/patch?hl=JA
I wrote below code
var requestdata = {
appsId: PROJECT_NAME,
servicesId: SERVICE_ID,
versionsId: VERSION_ID,
auth: authClient,
automaticScaling: {
standardSchedulerSettings:
{
maxInstances: 0,
minInstances: 0
}
},
}
appengine.apps.services.versions.patch(requestdata);
But it is not work well.
I encounter this error message.
Error: function crashed. Details:
Invalid JSON payload received. Unknown name "automaticScaling[standardSchedulerSettings][maxInstances]": Cannot bind query parameter. Field 'automaticScaling[standardSchedulerSettings][maxInstances]' could not be found in request message.
Invalid JSON payload received. Unknown name "automaticScaling[standardSchedulerSettings][minInstances]": Cannot bind query parameter. Field 'automaticScaling[standardSchedulerSettings][minInstances]' could not be found in request message.
I do not know how to solve the problem.
If you have any advice, please let me know.
This is because standardSchedulerSettings is not a valid parameter as it does not exist in v1beta5.
As of January 2019, the Admin API was upgraded from v1beta -> V1.
The v1beta4 and v1beta5 versions of the API are no longer supported and scheduled for shut down on January 14, 2019.
To resolve this just update any old dependencies you may have to the latest version and make sure to follow the latest V1 apps.services.versions.patch documentation .
This worked for me.

Apache Zeppelin - error: overloaded method value run with alternatives

I am trying to use the angular binding feature available in Apache Zeppelin in the following code:
val ab10 = z.sqlContext.sql("select "+ z.angular("selectVari0") + " from MyDF")
ab10.toDF.registerTempTable("ab0")
z.angularBind("abb0", ab10)
val selvar = z.getInterpreterContext()
z.angularUnwatch("abb0")
z.angularWatch("abb0", (before:Object, after:Object) => {
z.run(15, selvar)
})
I get the following error:
ab10: org.apache.spark.sql.DataFrame = [BMI: double]
warning: there was one deprecation warning; re-run with -deprecation for details
selvar: org.apache.zeppelin.interpreter.InterpreterContext = org.apache.zeppelin.interpreter.InterpreterContext#216b8218
<console>:31: error: overloaded method value run with alternatives:
(x$1: java.util.List[Object],x$2: org.apache.zeppelin.interpreter.InterpreterContext)Unit <and>
(x$1: String,x$2: String)Unit
cannot be applied to (Int, org.apache.zeppelin.interpreter.InterpreterContext)
z.run(15, selvar)
^
I tried anther example from here. I got similar errors. I was not able to find any documentation to fix this error.
As stated in error message, you have to overloaded .run methods, with following signatures:
(x$1: java.util.List[Object],x$2: org.apache.zeppelin.interpreter.InterpreterContext)Unit <and>
(x$1: String,x$2: String)Unit
Please, try to call it like this:
import collection.JavaConverters._
z.run(List(15).asJava, selvar)

solr query exception ! how is that going on?

i use solr 4.3 for my website ,
whie i query one data with morelike this function ,
sometime this exception goes out :
org.apache.solr.common.SolrException: parsing error
at org.apache.solr.client.solrj.impl.BinaryResponseParser.processResponse(BinaryResponseParser.java:43)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:385)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
parsing error??
how was it ?
why it occures ?
thanks for your reply .
this code :
the code :
public MoreLikeThisQueryResponse(QueryResponse queryResponse) {
this.queryResponse = queryResponse;
NamedList<Object> res = this.queryResponse.getResponse();
for (int i = 0; i < res.size(); i++) {
String name = res.getName(i);
if ("match".equals(name)) {
this.matchResult = (SolrDocumentList) res.getVal(i);
}
}
}
This type of "parsing error" in the BinaryResponseParser.processResponse method typically indicates that the server is returning a raw HTML text response rather than a Solr javabin response. Typically that means that the server container (Tomcat or Jetty) is detecting and reporting an error before Solr gets a chance to handle the error and obey the wt parameter which sets the response format to javabin.
Check the server log for the actual error.
I had a similar problem.
It seems that there might be a compatibility error is your are not using the EXACT compatible versions of Solr and Solrj.
To resolve this, you have to specify
server.setParser(new XMLResponseParser());
Quoting from Solrj
SolrJ generally maintains backwards compatibility, so you can use a newer SolrJ with an older Solr, or an older SolrJ with a newer Solr. There are some minor exceptions to this general rule:
If you're mixing 1.x and a later major version, you must set the response parser to XML, because the two versions use incompatible versions of javabin.

mpdf no output and php errors in mpdf.php

I'm trying to generate a pdp file in a cakephp application. Therefore, I use the mpdf library as a vendor. But when I try to make a even very simple output it doesn't work. Then when I use the debug property, it shows php errors in the mpdf.php file.
Here is my source code:
<?php
$mpdf=new mPDF();
$mpdf->WriteHTML('hello');
$mpdf->debug = true;
$mpdf->Output();
exit;
?>
And these are the errors shown in the browser:
Notice (8): Undefined index: BODY [APP\vendors\MPDF54\mpdf.php, line 14242]
Notice (8): Undefined index: BODY>>ID>> [APP\vendors\MPDF54\mpdf.php, line 14288]
Notice (8): Undefined offset: -1 [APP\vendors\MPDF54\mpdf.php, line 14421]
Thank you for your help!
This is not a CakePHP problem but related to the library you're using.
Read about how to use the WriteHTML() method.
http://mpdf1.com/manual/index.php?tid=121
And try passing 2 as the 2nd argument.
$mpdf->WriteHTML('hello', 2);
If this still does not work read the documentation, check the examples there.
This is caused by buggy mpdf code. It depends on error (level "notice") reporting to be switched off (it switches it off itself). But if you handle errors some nonstandard way, it is problem..
I solved it by ignoring errors from mpdf.php file in my custom error handler.
I was using my custom error reporting via set_error_handler();

Resources