neo4J error: Neo.ClientError.Procedure.ProcedureCallFailed - algorithm

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|

Related

How do I set the number of results return from completion/suggest?

Currently, I have the Elasticsearch service running on version 7.4.0 while my C# Windows Form application is using Elasticsearch.Net version 7.3.1.
I notice I could set the maximum number of results returned from highlight by setting NumberOfFragments which by default is five. However, I could not get the completion/suggestion to return more than five results when I set the following:
var tRes = client.Search<Words>(s => s
.SuggestSize(20) // How many suggestions to return in response
.Suggest(su => su
.Completion("name", cs => cs
.SkipDuplicates(true)
.Field(f => f.Suggest)
.Prefix(tbInput.Text)
.Regex("*")
.Size(20))
)
I received the following error message when I execute the above query.
{"The remote server returned an error: (400) Bad Request.. Call: Status code 400 from: POST /docproperty/_search?typed_keys=true&suggest_size=20. ServerError: Type: illegal_argument_exception Reason: \"request [/docproperty/_search] contains unrecognized parameter: [suggest_size] -> did you mean [suggest_field]?\""}
Update
I manage to get more than 5 results by adding the following:
var tRes = client.Search<Words>(s => s
.Size(20)
.Suggest(su => su
.Completion("name", cs => cs
.SkipDuplicates(true)
.Field(f => f.Suggest)
.Prefix(tbInput.Text)
.Regex("*")
.Size(20))
.Term("", t=>t.ShardSize(20).Field(f=>f.Suggest).Text(tbInput.Text))
)
);
However, this time I notice that I could not get the completion to return words (a lot of missing ones) that could be found when I execute a MatchPhrase.
I think if you look at the documentation, I think it's not meant to be suggestSize. I think it should be size only.. not sure if this supports chaining.
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html

Clojure: using ragtime with sqlite3

I'd like to use ragtime to manage migrations on an SQLite database. Following the instructions here, i've tried the following in the REPL:
(require '[ragtime.jdbc :as jdbc]
'[ragtime.repl :as repl])
(def config
{:datastore (jdbc/sql-database {:connection-uri "jdbc:sqlite:resources/db.sqlite3"})
:migrations (jdbc/load-resources "migrations")})
(repl/migrate config)
All I get is the following error:
ClassCastException clojure.lang.PersistentVector cannot be cast to clojure.lang.Named clojure.core/name (core.clj:1546)
The database file exists in resources/db.sqlite3. I've tried tracing the exception (i can add the stack trace if needed), but it seems to happen deep in clojure.java.jdbc.
As I'm new to the JVM and JDBC, I'm also not sure whether I'm specifying the :connection-uri correctly; I've tried several variants but can't seem to make it worK.
Any help would be much appreciated !
EDIT: stack trace:
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Named
at clojure.core$name.invokeStatic (core.clj:1546)
clojure.core$name.invoke (core.clj:1540)
clojure.java.jdbc$as_sql_name.invokeStatic (jdbc.clj:67)
clojure.java.jdbc$as_sql_name.invoke (jdbc.clj:56)
clojure.java.jdbc$create_table_ddl$spec_to_string__2511.invoke (jdbc.clj:1052)
clojure.core$map$fn__4785.invoke (core.clj:2646)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.LazySeq.first (LazySeq.java:71)
clojure.lang.RT.first (RT.java:667)
clojure.core$first__4339.invokeStatic (core.clj:55)
clojure.string$join.invokeStatic (string.clj:180)
clojure.string$join.invoke (string.clj:180)
clojure.java.jdbc$create_table_ddl.invokeStatic (jdbc.clj:1056)
clojure.java.jdbc$create_table_ddl.doInvoke (jdbc.clj:1041)
clojure.lang.RestFn.invoke (RestFn.java:423)
ragtime.jdbc$migrations_table_ddl.invokeStatic (jdbc.clj:16)
ragtime.jdbc$migrations_table_ddl.invoke (jdbc.clj:15)
ragtime.jdbc$ensure_migrations_table_exists.invokeStatic (jdbc.clj:22)
ragtime.jdbc$ensure_migrations_table_exists.invoke (jdbc.clj:20)
ragtime.jdbc.SqlDatabase.applied_migration_ids (jdbc.clj:42)
ragtime.core$migrate_all.invokeStatic (core.clj:43)
ragtime.core$migrate_all.invoke (core.clj:32)
ragtime.repl$migrate.invokeStatic (repl.clj:49)
ragtime.repl$migrate.invoke (repl.clj:34)
thulium.core$eval8407.invokeStatic (form-init2686611279014890656.clj:1)
(the rest is REPL and compiler calls)
And the two migration files, resources/migrations/001-initial.up.sql:
CREATE TABLE tests (
id INTEGER PRIMARY KEY AUTOINCREMENT
);
and resources/migrations/001-initial.down.sql:
DROP TABLE tests;
Give it a go with these versions:
[org.clojure/java.jdbc "0.6.1"]
[org.xerial/sqlite-jdbc "3.8.7"]

How to measure moped insert runtime in a ruby mongoid app?

I'm currently writing a moped log parser in order to monitor moped queries runtime.
It's work great for QUERY command using the runtime parameter, but INSERT and UPDATE have no runtime parameter. All INSERT and UPDATE are followed by a getLastError COMMAND which contains a runtime.
Here are some samples of moped logs:
QUERY with runtime
MOPED: 127.0.0.1:27017 QUERY database=X collection=X selector=X
flags=[] limit=-1 skip=0 batch_size=nil fields=nil runtime: 0.6950ms
INSERT without runtime but with COMMAND
MOPED: 127.0.0.1:27017 INSERT database=X collection=X documents=X flags=[]
COMMAND database=X command={:getlasterror=>1, :w=>1}
runtime: 0.4750ms
I'm pretty sure that COMMAND runtime is for the getlasterror call and not for my INSERT one.
So is there a way to get this runtime info for an INSERT query?
Instead of using a log parser, I use something like this and it works great:
ActiveSupport::Notifications.subscribe('query.moped') do |name, start, finish, id, payload|
runtime = (finish - start)*1000
moped_ops = payload[:ops]
moped_ops.each do |op|
unless op.collection == '$cmd'
query = op.class.name.split('::').last.downcase
query = op.selector.first[0].to_s.gsub(/\$/, '') if query == 'command'
DO SOMETHING WITH #{op.database}.#{op.collection}.#{query}
end
end
end

Test the existence of a Teradata table and create the table if non-existent

Our Continuous Inegration server (Hudosn) is having a strange issue when attempting to run a simple create table statement in Teradata.
This statement tests the existence of the max_call table:
unless $teradata_connection.table_exists? :arm_custom_db__max_call_attempt_parameters
$teradata_connection.run('CREATE TABLE all_wkscratchpad_db.max_call_attempt_parameters AS (SELECT * FROM arm_custom_db.max_call_attempt_parameters ) WITH NO DATA')
end
The table_exists? method does the following:
def table_exists?(name)
v ||= false # only retry once
sch, table_name = schema_and_table(name)
name = SQL::QualifiedIdentifier.new(sch, table_name) if sch
from(name).first
true
rescue DatabaseError => e
if e.to_s =~ /Operation not allowed for reason code "7" on table/ && v == false
# table probably needs reorg
reorg(name)
v = true
retry
end
false
end
So as per the from(name).first line, the test which this method is performing is just a simple select statement, which, in SQL, looks like: SELECT TOP 1 MAX(CAST(MAX_CALL_ATTEMPT_CNT AS BIGINT)) FROM ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS
The above SQL statement executes perfectly fine within Teradata SQL Assistant, so it's not a SQL syntax issue. The generic ID which our testing suite (Rubymine) uses is also not the issue; that ID has select access to the arm_custom_db.
The exeption which I can see is being thrown (within the builds console output on Hudson) is
Sequel::DatabaseError: Java::ComTeradataJdbcJdbc_4Util::JDBCException. Since this execption is a subclass of DatabaseError, the exception shouldn't be the problem either.
Also: We use unless statements like this every day for hundreds of different tables, and all except this one work correctly. This statement just seems to be a problem.
The complete error message which appears in the builds console output of Hudson is as follows:
[2015-01-07T13:56:37.947000 #16702] ERROR -- : Java::ComTeradataJdbcJdbc_4Util::JDBCException: [Teradata Database] [TeraJDBC 13.10.00.17] [Error 3807] [SQLState 42S02] Object 'ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS' does not exist.: SELECT TOP 1 MAX(CAST(MAX_CALL_ATTEMPT_CNT AS BIGINT)) FROM ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS
Sequel::DatabaseError: Java::ComTeradataJdbcJdbc_4Util::JDBCException: [Teradata Database] [TeraJDBC 13.10.00.17] [Error 3807] [SQLState 42S02] Object 'ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS' does not exist.
I don't understand why this specific bit of code is giving me issues...there does not appear to be anything special about this table or database, and all SQL code executes perfectly fine in Teradata when I am signed in with the same exact user ID that is being used to execute the code from Hudson.

ruby driver for mongodb : update method returns Fixnum, not Hash

I'm debugging a problem where occasional writes to a mongo collection seem to be failing. As I was going over my error checking code, I found that the update method in the Collection class, seems to be returning a Fixnum instead of a hash.
Here is a code fragment (with debug statements)
begin
puts "collection type: #{#db_collection.class}"
status = #db_collection.update(selector, document)
puts "[Warn] Database update returned NULL status" unless status
puts "[Error] Mongo update returned an error: #{status.class}" unless (status == true)
puts "[Error] Mongo update returned an error: #{status}" unless (status == true)
rescue => e
puts "[Warn] Unable to update mongoDB (#{e})"
end
When I run this code, I get the following output:
collection type: Mongo::Collection
[Error] Mongo update returned an error: Fixnum
[Error] Mongo update returned an error: 236
I was expecting the update function to return a true for successful operations and a Hash for fails as per the documentation:
Returns:
(Hash, true) — Returns a Hash containing the last error object if acknowledging writes. > Otherwise, returns true.
I'm using version 1.8.0 of the ruby driver.
I'm not sure how to properly check that the writes have occurred correctly. I know that the driver should throw an exception if the write fails but I'm not seeing that happen. I don't know how to properly check the status variable since it's not returning a type I expect.
Thanks in advance for any help here.

Resources