Cannot create index in JanusGraph - elasticsearch

I've installed JanusGraph 0.5.2 with ScyllaDB 4.2.1 and Elasticsearch 6.6.0 and I'm trying to create a fulltext index according to the docs as follows:
1. mgmt = graph.openManagement()
2. PropertyKey value = mgmt.makePropertyKey('value').dataType(String.class).make()
3. mgmt.buildIndex('verticesByValue', Vertex.class).addKey(value, Mapping.TEXT.asParameter()).buildMixedIndex("search")
4. mgmt.commit()
It throws this error after I enter the 3. step:
No signature of method: org.janusgraph.graphdb.database.management.ManagementSystem$IndexBuilder.addKey() is applicable for argument types: (org.apache.tinkerpop.gremlin.structure.T$4, org.janusgraph.core.schema.Parameter) values: [value, mapping->TEXT]

Instead of:
PropertyKey value = mgmt.makePropertyKey('value').dataType(String.class).make()
Use This:
value = mgmt.makePropertyKey('value').dataType(String.class).make()
I was able to generate the issue when I used "PropertyKey" type to assign to value.

Related

neo4J error: Neo.ClientError.Procedure.ProcedureCallFailed

I am trying to run the following code.
CALL gds.graph.create.cypher(
'my-cypher-graph',
'MATCH (n:Person) RETURN id(n) AS id',
'MATCH (a:Person)-[:LIKES]->(b:Person) RETURN id(a) AS source, id(b) AS target'
)
YIELD graphName, nodeCount, relationshipCount, createMillis;
But I got this error: Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure gds.graph.create.cypher: Caused by: java.lang.IllegalArgumentException: Node-Query returned no nodes
I am running Neo4J 4.1.0
Can you please help?
This was happening because the db had 0 nodes. The gds.graph.create.cypher function actually does not CREATE the nodes.
So this question is answered. Thanks.
#Check for appropriate version for neo4j and GDS library from that git file
https://github.com/neo4j/graph-data-science
# first create a node and relationship
create (:Person{name:"Oliver Stone"})-[:LIKE]->(:Person{name:"Karan Kajrolkar"})
#Then try to create native projection
CALL gds.graph.create(
'my-native-graph',
'Person',
'LIKE'
)
YIELD graphName, nodeCount, relationshipCount, createMillis;
#O/P
graphName|nodeCount|relationshipCount|createMillis|
"my-native-graph"|2 |1|51|

Google automl_v1beta1 error "the provided location ID is not valid"

I am trying to call trained model from google colab with example provided.
But there is an error.
Who knows is it beta error or I have not set somethoing properly?
Thanks in advance.
The code
from google.cloud import automl_v1beta1 as automl
automl_client = automl.AutoMlClient()
# Create client for prediction service.
prediction_client =
automl.PredictionServiceClient().from_service_account_json(
'XXXXX.json')
# Get the full path of the model.
model_full_id = automl_client.model_path(
project_id, compute_region, model_id
)
# Read the file content for prediction.
#with open(file_path, "rb") as content_file:
snippet = "fsfsf" #content_file.read()
# Set the payload by giving the content and type of the file.
payload = {"text_snippet": {"content": snippet, "mime_type": "text/plain"}}
# params is additional domain-specific parameters.
# currently there is no additional parameters supported.
params = {}
response = prediction_client.predict(model_full_id, payload, params)
print("Prediction results:")
for result in response.payload:
print("Predicted class name: {}".format(result.display_name))
print("Predicted class score: {}".format(result.classification.score))
The eror msg^
InvalidArgument: 400 List of found errors: 1.Field: name; Message: The provided location ID is not valid.
You have to use a region that supports AutoML beta. This works for me:
create_dataset("myproj-123456", "us-central1", "my_dataset_id", "en", "de")
I clone the repo "python-docs-samples" :
$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
I navigate to the automl examples
$ cd /home/MY_USER/python-docs-samples/language/automl/
I set the environment variables for [1]:
GOOGLE_APPLICATION_CREDENTIALS
PROJECT_ID
REGION_NAME
I typed:
$ python automl_natural_language_dataset.py create_dataset automltest1 False
I got this message:
Dataset name: projects/198768927566/locations/us-central1/datasets/TCN7889001684301386365
Dataset id: TCN7889001684301386365
Dataset display name: automltest1
Text classification dataset metadata:
classification_type: MULTICLASS
Dataset example count: 0
Dataset create time:
seconds: 1569367227
nanos: 873147000
I set the environment variable for :
DATASET_ID
Please note that I got this for the step 5.
I typed:
python automl_natural_language_dataset.py import_data $DATASET_ID "gs://$PROJECT_ID-lcm/complaints_manual.csv"
I got this message:
Processing import...
Dataset imported.

Elasticsearch - Convert Json Strin to XcontentBuilder

I was using elasticsearch 6.2.2. and this is how I convert json string to Xcontentbuilder.
XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint();
XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, jsonObj.toString());
builder.copyCurrentStructure(parser);
I worked well until I updated elasticsearch 6.3+.
There is error on ES 6.3+ with same code.
Description Resource Path Location Type The method
createParser(NamedXContentRegistry, DeprecationHandler, String) in the
type JsonXContent is not applicable for the arguments
(NamedXContentRegistry, String) test.java
The Compile Error has called out: your createParser miss a DeprecationHandler parameter.
So you should set the DeprecationHandler, for example:
JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY,
LoggingDeprecationHandler.INSTANCE,
jsonObj.toString());

Container::getAlias($abstract) throws ErrorException: Illegal offset type in isset or empty when $abstract there is not in $this->aliases[]

Laravel Version: 5.6.16
PHP Version: 7.2.3
Database Driver & Version: N/A
Description:
laravel\framework\src\Illuminate\Container\Container.php public function getAlias($abstract)
throws ErrorException: Illegal offset type in isset or empty
when $abstract there is not in $this->aliases[]
$this->aliases[$abstract] is null and !isset($this->aliases[$abstract]) throws ErrorException: Illegal offset type in isset or empty
$abstract value is Modules\Administration\Tests\Commands\StubJsonCommandHandler
Steps To Reproduce:
Run AdministrationControllerTest (https://github.com/proyectotau/TAU/ clone laraveldusk branch [4ef9b0e124657abed7afde0969f332bf7be95a8b])
Is it a bug or I have any mistake? Thanks in advance!
When binding an instance to the container, please make sure you are using:
app()->instance('dependency', $instantiation);
not,
app()->bind('dependency', $instantiation); // DON'T bind an instance
Attempting to bind an instance will result an error, as the container tries to index possible aliases using a concrete object as opposed to a type.
Workaround
Change in getAlias() function
! isset($this->aliases[$abstract])
for
! isset($this->aliases[(string)$abstract])
Or change explicitly type-hint to string at ALL functions (#param string is not enough)
public function getAlias($abstract)
for
public function getAlias(string $abstract)
But it fails later in next use of [$abstract] in Container:
isShared() at isset($this->instances[(string)$abstract]) isset($this->bindings[(string)$abstract]
resolve() calling to$this->resolved[(string)$abstract] = true;
getConcrete() at if (isset($this->bindings[(string)$abstract]))
getContextualConcrete() at if (empty($this->abstractAliases[(string)$abstract]))
getExtenders() at if (isset($this->extenders[(string)$abstract]))
and in Illuminate\Foundation\Application:
make() at if (isset($this->deferredServices[(string)$abstract]) && ! isset($this->instances[(string)$abstract]))
PS: Please have a look to Alvaro Gonzalez's comment in
php - How do I fix this illegal offset type error
I finally found out the issue was send params like ::class which can not be used as an array index.
Strings must be instead

MongoDB update using Java 3 driver

I'm switching to the MongoDB Java driver version 3. I cannot figure out how to perform an update of a Document. For example, I want to change the "age" of an user:
MongoDatabase db = mongoClient.getDatabase("exampledb");
MongoCollection<org.bson.Document> coll = db.getCollection("collusers");
Document doc1 = new Document("name", "frank").append("age", 55) .append("phone", "123-456-789");
Document doc2 = new Document("name", "frank").append("age", 33) .append("phone", "123-456-789");
coll.updateOne(doc1, doc2);
The output is:
java.lang.IllegalArgumentException: Invalid BSON field name name
Any idea how to fix it ?
Thanks!
Use:
coll.updateOne(eq("name", "frank"), new Document("$set", new Document("age", 33)));
for updating the first Document found. For multiple updates:
coll.updateMany(eq("name", "frank"), new Document("$set", new Document("age", 33)));
On this link, you can fine a quick reference to MongoDB Java 3 Driver
in Mongodb Java driver 3.0 , when you update a document, you can call the coll.replaceOne method to replace document, or call the coll.updateOne / coll.updateMany method to update document(s) by using $set/$setOnInsert/etc operators.
in your case, you can try:
coll.updateOne(eq("name", "frank"), new Document("$set", new Document("age", 33)));
coll.replaceOne(eq("name", "frank"), new Document("age", 33));
You can try this
coll.findOneAndReplace(doc1, doc2);

Resources