Coder Social home page Coder Social logo

neo4jrb / neo4j-core Goto Github PK

View Code? Open in Web Editor NEW
99.0 14.0 80.0 22.56 MB

A simple unified API that can access both the server and embedded Neo4j database. Used by the neo4j gem

License: MIT License

Ruby 99.45% HTML 0.32% Dockerfile 0.23%
neo4j driver adaptor ruby graph-database

neo4j-core's People

Contributors

amiel avatar amitsuryavanshi avatar andreasronge avatar ausmarton avatar brucek avatar cheerfulstoic avatar collin avatar dominikgrygiel avatar dsisnero avatar dwbutler avatar heavydawson avatar jboler avatar jgaskins avatar klobuczek avatar kmussel avatar kunitoo avatar miharekar avatar mrstif avatar nenenene0 avatar ni-ka avatar olleolleolle avatar plukevdh avatar progm avatar ricardotrindade avatar smcintosh avatar subvertallchris avatar telzul avatar ujjwalt avatar vpacher avatar wardcunningham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neo4j-core's Issues

Ability to create unique relationships

I don't think there is a way to create unique relationships between two nodes as of now.
I was looking for something like what is mentioned here: http://docs.neo4j.org/chunked/milestone/query-create-unique.html#_create_unique_relationships

For example, if I'd want a student to be able to register to any class only once, then

student1.create_rel(:register, class1)
student1.create_rel(:register, class1)

would create two relationships (both of type :register) between student1 and class1.

It would be great if we could have a way of specifying that a relationship is unique.

DateTime property as invalid input error

Hi,

I'm not sure whether this should be here or in the neo4j v3 gem.

I have a node with a few properties set to type DateTime which is a valid type in active_attr. When trying to create a node with those properties set I get an Invalid input exception. Also compared this with the neo4jrb v2 gem this property was translated into an integer (epoch).

Should this translation happen in the Neo4j::Core::Cyphertranslator ? Is there any thoughts or work related to this or should I give it a shot ?

Handle update_props with nil values

It should delete the properties if it is nil

see neo4jrb/activegraph#319

Gives currently the following error:

Neo4j::Server::CypherResponse::ResponseError: Invalid input ',': expected whitespace, comment or an expression (line 1, column 74)
"START n=node(443) SET n.`updated_at`= 1391775140,n.`confirmation_token`= ,n.`confirmed_at`= 1391775140"
                                                                          ^
    neo4j-core (3.0.0.alpha.8) lib/neo4j-server/cypher_response.rb:84:in `raise_error'
    neo4j-core (3.0.0.alpha.8) lib/neo4j-server/cypher_session.rb:121:in `_query_or_fail'

Cypher: Mixing Where and Match clauses

The Cypher DSL should take care of the order of clauses so that one can write

node(1) > (rel(:knows)[:since] > 1994) > (node(:other)[:name] == 'foo'); :other

Which is same as

START n0=node(1) MATCH (n0)-[v1:`knows`]->(other) WHERE v1.since > 1994 and other.name = "foo" RETURN other

Undefined method >> for Symbol

This works:

jruby-1.6.7 :045 > Neo4j::Cypher.new { node(1) > :r > :end > :bar}.to_s
 => "START n0=node(1) MATCH m2 = (n0)-[r]->(end)-[bar] RETURN m2" 

But this does not work

jruby-1.6.7 :046 > Neo4j::Cypher.new { (node(1) > :r > :end) >> :bar}.to_s

Support for basic authentication in the REST API (neo4j-core v3.0)

I was using the GrapheneDB addon on heroku which provides a basic authenticated neo4j service via REST for which, they provide a url like:

http://<username>:<password>@<host>:<port>

Now, the REST support in neo4j-core v3.0 does not allow basic auth parameters, and hence you end up getting a response code of 401 by GrapheneDB.

cypher_session.rb at line 5 https://github.com/andreasronge/neo4j-core/blob/master/lib/neo4j-server/cypher_session.rb#L5

response = HTTParty.get(endpoint_url || 'http://localhost:7474')

doesn't have any provision to accept auth credentials as of now.

But HTTParty by itself, does allow basic auth options like this:

HTTParty.get("http://host:port", 
                     basic_auth: { username: "user", password: "p@ssw0rd" })

Creating connections with Neo4j::Relationship

Hi Andreas,

Creating relationships between two nodes works with the method below, but not with Neo4j::Relationship. Any plans to integrate Neo4j::Relationship? Thanks.

n1 = Neo4j::Node.create({name: 'andreas'}, :person)
n2 = Neo4j::Node.create({name: 'burak'}, :person)

rel = n1.create_rel(:friend, n2)
Neo4j::Relationship.new(:friend, n1, n2)

ArgumentError: wrong number of arguments calling `initialize` (3 for 0)
    from (irb):20:in `evaluate'
    from org/jruby/RubyKernel.java:1093:in `eval'
    from org/jruby/RubyKernel.java:1489:in `loop'
    from org/jruby/RubyKernel.java:1254:in `catch'
    from org/jruby/RubyKernel.java:1254:in `catch'
    from /Users/arikan/.rvm/rubies/jruby-1.7.4/bin/irb:13:in `(root)'

Replace Neo4j::Label.query with Neo4j::Session.query

I think we should only have one query method instead of Neo4j::Session.query and Neo4j::Label.query.

Example of usage

# with your own cypher string, with a cypher parameter p
Neo4j::Session.query("START n=node({p}) RETURN n", params: {p: 42})

# Returns all nodes with label 'person', 
# If there is no :return parameter it will try to return Neo4j::Node objects
# Default parameter is :n
Neo4j::Session.query(label: :person) # => MATCH (n:`person`) RETURN ID(foo)

# Using return
Neo4j::Session.query(label: :person, return: ['n.name', 'n.age']) 

# Using a different parameter instead of :n
Neo4j::Session.query(label: {p: :person:}, condition: {'p.age': 42}) # => MATCH (p:`person`) WHERE p.age = 42 RETURN ID(n)  # or RETURN n for embedded

# Using multiple label in match
Neo4j::Session.query(label: {p: :person: c: :company}, condition: {'p.age': 42}) # => MATCH (p:`person`), (c:`company`) WHERE p.age = 42 RETURN ID(n)  # or RETURN n for embedded

# Using match
Neo4j::Session.query(label: 'person', match: 'n--m', return: ['n.name', 'm.age']) 

# Using match and where
Neo4j::Session.query(label: 'person', match: 'n--m', where: 'm.age = 42', return: ['n.name', 'm.name']) 

# Using condition (similar to where)
Neo4j::Session.query(label: 'person', condition: {'n.age': 42}, return: ['n.name']) 

# Using condition with params
Neo4j::Session.query(label: 'person', condition: {'n.age': '{age}'}, params: {age: 42}, return: ['n.name']) 

Retrieval of nodes, properties and relationships

# without mapping of results
Neo4j::Session.query("START n=node(*) RETURN ID(n) AS id").each do |row|
  puts row[:id] # prints out the id of each node
end

with mapping of result to nodes

# map first column value to Neo4j::Node
Neo4j::Session.query("START n=node(*) RETURN n", map_result: [:node]).each do |row|
  puts row[:n].neo_id # prints out the id of each node
end

Using just one column

# map first column value to Neo4j::Node (since map_result is not an array)
Neo4j::Session.query("START n=node(*) RETURN n", map_result: :node).each do |node|
  puts node.neo_id # prints out the id of each node
end

Return several properties

# without mapping of results, print out the name and age properties of each person node
Neo4j::Session.query(label: 'person', return: ['n.name', 'n.age']).each do |row|
  puts row[:'n.name']
  puts row[:'n.age']
end

Retrieval with mapping of result to nodes,relationship, properties, array.

# map the first value returned from cypher to Neo4j::Node objects
Neo4j::Session.query(label: 'person', match: 'n-[r]->m', return: [:n, :r, 'm.age'], map_result: [:node, :rel, :any]).each do |row|
  puts row[:n].neo_id  # a Neo4j::Node or your own wrapper class
  puts row[:r].neo_id  # a Neo4j::Relationship or your own wrapper class
  puts row[:'m.age']  # a property
end

Shortcut, instead of using both return and map_result it can be combined. (I think we need both)
```ruby
Neo4j::Session.query(label: 'person', match: 'n-[r]->m', return: [{n: :node}, {r: :rel}, 'm.age']) 

Notice, when using the Neo4j Embedded database there is no need to specify mapping to nodes (map_result) and relationship. Maybe we can support that later for the server session when we get better support from the REST api.

How to access to the ref_node

I can not seem to access to the root node with version neo4j-core version 3. In the past neo4j.rb version it was Neo4j.ref_node now when I try it, I get this error below:

jruby-1.7.4 :001 > require 'neo4j-core'
 => true 
jruby-1.7.4 :002 > session = Neo4j::Session.open(:embedded_db, '/Users/arikan/Documents/Works/PenalSystems/db', auto_commit: true)
 => #<Neo4j::Embedded::EmbeddedSession:0x560a68d6 @auto_commit=true, @db_location="/Users/arikan/Documents/Works/PenalSystems/db"> 
jruby-1.7.4 :003 > session.start
Start embedded Neo4j db at /Users/arikan/Documents/Works/PenalSystems/db
 => [] 
jruby-1.7.4 :004 > Neo4j.ref_node
NoMethodError: undefined method `ref_node' for Neo4j:Module
    from (irb):4:in `evaluate'
    from org/jruby/RubyKernel.java:1093:in `eval'
    from org/jruby/RubyKernel.java:1489:in `loop'
    from org/jruby/RubyKernel.java:1254:in `catch'
    from org/jruby/RubyKernel.java:1254:in `catch'
    from /Users/arikan/.rvm/rubies/jruby-1.7.4/bin/irb:13:in `(root)'

cypher query with node(*) throw error.

Hi,
Following up with an issue posted to the neo4jrb google group,
Using jruby 1.6.7.2 and neo4j.rb 2.0.1, when I perform a cypher query with node() , the returned result cannot be iterated on.

Other queries work fine as long as the do not traverse all the node by using the node() method. This might be a jruby issue...

jruby-1.6.7.2 :123 > a = Neo4j._query("START n=node(*) RETURN n")
=> #>

jruby-1.6.7.2 :124 > a.first.columns
NativeException: java.lang.ClassCastException: org.jruby.gen.InterfaceImpl1557949290 cannot be cast to org.neo4j.kernel.GraphDatabaseAPI

from org/neo4j/tooling/GlobalGraphOperations.java:39:in '
from org/neo4j/tooling/GlobalGraphOperations.java:51:inat'
from org/neo4j/cypher/internal/executionplan/builders/GraphGlobalStartBuilder.scala:45:in apply'
from org/neo4j/cypher/internal/executionplan/builders/GraphGlobalStartBuilder.scala:45:inapply'
from org/neo4j/cypher/internal/pipes/StartPipe.scala:38:in apply'
from org/neo4j/cypher/internal/pipes/StartPipe.scala:37:inapply'
from scala/collection/TraversableLike.scala:200:in apply'
from scala/collection/TraversableLike.scala:200:inapply'
from scala/collection/LinearSeqOptimized.scala:59:in foreach'
from scala/collection/immutable/List.scala:45:inforeach'
from scala/collection/TraversableLike.scala:200:in flatMap'
from scala/collection/immutable/List.scala:45:inflatMap'
from org/neo4j/cypher/internal/pipes/StartPipe.scala:37:in createResults'
from org/neo4j/cypher/internal/pipes/ColumnFilterPipe.scala:37:increateResults'
from org/neo4j/cypher/internal/executionplan/ExecutionPlanImpl.scala:62:in apply'
from org/neo4j/cypher/internal/executionplan/ExecutionPlanImpl.scala:62:inapply'
... 2 levels...
from org/neo4j/cypher/PipeExecutionResult.scala:140:in hasNext'
from scala/collection/Iterator.scala:334:inhasNext'
from scala/collection/JavaConversions.scala:562:in hasNext'
from /Users/chrisfitzpatrick/.rvm/rubies/jruby-1.6.7.2/lib/ruby/site_ruby/shared/builtin/java/java.lang.rb:12:ineach'
from /Users/chrisfitzpatrick/.rvm/gems/jruby-1.6.7.2@beacon/gems/neo4j-core-2.0.1-java/lib/neo4j-core/cypher/result_wrapper.rb:32:in each'
from org/jruby/RubyEnumerable.java:326:infirst'

Use new API for accessing all nodes and relationships

The Neo4j Java API for accessing all nodes and relationship has change:
Code for warm up the database...

/*
* GraphWarmUp
 *
 * Helper class for cache warm up that iterates over all nodes and properties
 */
public class GraphWarmUp {

    public static int loadNodes(final GraphDatabaseService gdb, final boolean loadProps) {
        int i = 0;
        for (final Node n : GlobalGraphOperations.at(gdb).getAllNodes()) {
            // ensure node properties get loaded
            if (loadProps)
                n.getPropertyKeys();
            i += 1;
        }
        return i;
    }

    public static int loadRelationships(final GraphDatabaseService gdb, final boolean loadProps) {
        int i = 0;
        for (final Relationship r : GlobalGraphOperations.at(gdb).getAllRelationships()) {
            // ensure relationship properties get loaded
            if (loadProps)
                r.getPropertyKeys();
            i += 1;
        }
        return i;
    }
}

CypherTranslator wraps all property values in quotes while node creation

CypherTranslator, which is used during the generation of the Create node Cypher query, wraps all (property) values in quotes.
ref: https://github.com/andreasronge/neo4j-core/blob/master/lib/neo4j-core/cypher_translator.rb#L8

This causes all property values to be stored as strings in neo4j when created using neo4j-core.

For example, in the current implementation, it is not possible to generate a query like this:
session.query("CREATE (n:label { name : 'test', id: 2, version: 1.1 })")

The Cypher generated will always have Fixnums, booleans and everything wrapped in quotes like this:
session.query("CREATE (n:label { name : 'test', id: '2', version: '1.1' })")

Is this behaviour intended, or is it an issue that needs to be fixed?

missing lucene configuration

with

Neo4j::Node.trigger_on(:type => "person")
Neo4j::Node.index :name                                                                                                                  
Neo4j::Node.new :name => "tom", :type => "person"

I get this exception

ERROR in before commit hook undefined method `[]' for nil:NilClass
/Users/tom/.rvm/gems/jruby-1.7.1@dynomutt/gems/neo4j-core-2.2.3-java/lib/neo4j-core/index/indexer.rb:231:in `lucene_config'
/Users/tom/.rvm/gems/jruby-1.7.1@dynomutt/gems/neo4j-core-2.2.3-java/lib/neo4j-core/index/indexer.rb:243:in `create_index_with'
/Users/tom/.rvm/gems/jruby-1.7.1@dynomutt/gems/neo4j-core-2.2.3-java/lib/neo4j-core/index/indexer.rb:215:in `index_for_field'
/Users/tom/.rvm/gems/jruby-1.7.1@dynomutt/gems/neo4j-core-2.2.3-java/lib/neo4j-core/index/indexer.rb:70:in `add_index'
/Users/tom/.rvm/gems/jruby-1.7.1@dynomutt/gems/neo4j-core-2.2.3-java/lib/neo4j-core/index/indexer.rb:192:in `update_index_on'
/Users/tom/.rvm/gems/jruby-1.7.1@dynomutt/gems/neo4j-core-2.2.3-java/lib/neo4j-core/index/indexer_registry.rb:31:in `on_property_changed'
/Users/tom/.rvm/gems/jruby-1.7.1@dynomutt/gems/neo4j-core-2.2.3-java/lib/neo4j-core/index/indexer_registry.rb:23:in `each_indexer'
org/jruby/RubyArray.java:1612:in `each'

The only config I have in Neo4j::Config is :storage_path (nothing for :lucene)
Using a debugger, it looks like it's trying to find a lucene config for type "exact".
It's not clear what needs to be added, as described in the lucene config section

Rake neo4j:install[community-2.1.1] is broken

Looks like old version does not work
Installing the current latest does however work.
Should have better error message, or maybe download the latest when no arguments are given.

README Incorrect Regarding 3.0.0 branches and status?

I am messing around with Neo4J.rb experimentally and want to use MRI so I am installing 3.0.0-alpha5.

The README in the master branch (Which I am assuming is now the 3.x branch) says that the Neo4j-wrapper is included (as well as some stuff about lib and lib.old) but as far as I can see this is not the case in the master branch and there is no "3.0.0" branch (There IS a 4.0.0 branch which seems to fir the bill but... well it is 4.0.0...)

What is the current status for those of us that want to mess around with neo4j-wrapper with neo4j-core 3.0.0-alpha5 on MRI?

settings $NEO4J_SERVER fails when Neo4j.start is called

Hello,

I am settings $NEO4J_SERVER in my config.ru :

require 'neo4j-core'
$NEO4J_SERVER = org.neo4j.kernel.EmbeddedGraphDatabase.new("db/neo4j-development", Neo4j::Config.to_java_map)
at_exit{$NEO4J_SERVER}

I'm getting the following error :

NoMethodError (private method `start_external_db' called for #<Neo4j::Core::Database:0x7303754a>):
  neo4j-core-2.0.0 (java) lib/neo4j/neo4j.rb:39:in `start'
  neo4j-core-2.0.0 (java) lib/neo4j/neo4j.rb:71:in `started_db'
  neo4j-2.0.0 (java) lib/neo4j/rails/rack_middleware.rb:36:in `call'
  sass (3.1.2) lib/sass/plugin/rack.rb:54:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.1) lib/rack/etag.rb:23:in `call'
  rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
  rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/cookies.rb:338:in `call'
  activerecord (3.2.3) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
  activesupport (3.2.3) lib/active_support/callbacks.rb:408:in `_run__1745543348__call__439037176__callbacks'
  org/jruby/RubyKernel.java:2076:in `send'
  activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.3) lib/active_support/callbacks.rb:390:in `_run_call_callbacks'
  org/jruby/RubyKernel.java:2076:in `send'
  activesupport (3.2.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:in `call'
  railties (3.2.3) lib/rails/engine.rb:479:in `call'
  railties (3.2.3) lib/rails/application.rb:220:in `call'
  org/jruby/RubyKernel.java:2080:in `send'
  railties (3.2.3) lib/rails/railtie/configurable.rb:30:in `method_missing'
  rack (1.4.1) lib/rack/static.rb:66:in `call'
  rack (1.4.1) lib/rack/builder.rb:134:in `call'
  rack (1.4.1) lib/rack/urlmap.rb:64:in `call'
  org/jruby/RubyArray.java:1615:in `each'
  rack (1.4.1) lib/rack/urlmap.rb:49:in `call'
  rack (1.4.1) lib/rack/lint.rb:48:in `_call'
  rack (1.4.1) lib/rack/lint.rb:36:in `call'
  rack (1.4.1) lib/rack/showexceptions.rb:24:in `call'
  rack (1.4.1) lib/rack/commonlogger.rb:20:in `call'
  mizuno (0.6.3) lib/mizuno/rack/chunked.rb:16:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  mizuno (0.6.3) lib/mizuno/rack_servlet.rb:83:in `service'
  org/jruby/RubyKernel.java:1183:in `catch'
  mizuno (0.6.3) lib/mizuno/rack_servlet.rb:82:in `service'
  mizuno (0.6.3) lib/mizuno/rack_servlet.rb:247:in `handle_exceptions'
  mizuno (0.6.3) lib/mizuno/rack_servlet.rb:53:in `service'

Cheers

Upgrade to >=1.8.M05

1.8.M05 has breaking changes, some traversals methods now uses path parameters instead of simply a node or relationship

Better hash from query enumeration

With multiple fields in the response, each field now gets its own row, like:

{:"name" => "Foo"}
{:"age" => 20}
{:"name" => "Bar"}
{:"age" => 127}

I mokeypatched Neo4j::Server::CypherResponse::HashEnumeration.each thusly:

    def each()
      data.each do |row|
        hash = {}

        row.each_with_index do |row, i|
          hash[columns[i].to_sym] = row
        end
        yield hash
      end
    end

That way I ended up with what I would have expected:

{:"name" => "Foo", :"age" => 20}
{:"name" => "Bar", :"age" => 127}

Escape strings better

Neo balks at strings that include patterns like "\somedir\file\c$\more\paths" and returns a Neo4j::Server::CypherResponse::ResponseError

I realize this is a core Neo4j issue, but is there any good way to sanitize these strings before trying to commit them?

missing dependency error with neo4j-core 3.0.0.alpha.2

after installing the alpha version

gem install neo4j-core -v 3.0.0.alpha.2

tried in irb and got the following error:

jruby-1.7.4 :001 > require 'neo4j-core'

NameError: cannot link Java class org.neo4j.graphdb.DynamicLabel, probable missing dependency: org/neo4j/graphdb/DynamicLabel : Unsupported major.minor version 51.0
from org/jruby/javasupport/JavaClass.java:1242:in `for_name'

What would be wrong here, also here is my gem list:

*** LOCAL GEMS ***
bouncy-castle-java (1.5.0147)
bundler (1.3.5)
bundler-unload (1.0.2)
coderay (1.1.0)
executable-hooks (1.2.6)
ffi (1.9.3 java)
gem-wrappers (1.2.1)
httparty (0.12.0)
jruby-launcher (1.0.19 java)
jruby-openssl (0.9.4)
json (1.8.1 java)
method_source (0.8.2)
multi_xml (0.5.5)
neo4j-community (2.0.0 java)
neo4j-core (3.0.0.alpha.2)
neo4j-cypher (1.0.2)
pry (0.9.12.4 java)
rake (10.0.3)
rubygems-bundler (1.4.2)
rvm (1.11.3.8)
slop (3.4.7)
spoon (0.0.4)

Cleaner for Testability

It's a bit hard to write tests against Neo4j without a way to dump the data between tests as needed. Any chance we can add a method like #flushall or #dropall or whatever to the session that runs something similar to:

session.query("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r")

Would make it much easier to write integration tests and test actual persistence.

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Upgrade to Neo4j 1.7.1 and use PathEvaluator

Can't call the Interface org.neo4j.graphdb.traversal.TraversalDescription without getting JRuby warnings since JRuby guess which method should be used when the method has the same name but with different arguments,

see https://groups.google.com/forum/?fromgroups#!topic/jruby-users/gUrc5pBfCiM

ALways use the evaluator with PathEvaluator as argument, see http://api.neo4j.org/1.8.1/org/neo4j/graphdb/traversal/TraversalDescription.html#evaluator(org.neo4j.graphdb.traversal.PathEvaluator)

How can I extract Neo4j::Node objects from a Cypher query?

The docs clearly explain how to issue a Cypher query with Neo4j-core 3.0:

session = Neo4j::Session.current
result = session.query(
  "START v1=node(148) MATCH (v1)-[:children]->(v2) RETURN v2")

This gives me a Neo4j::Server::CypherResponse::HashEnumeration. As expected, q.first[:v2] gives me data corresponding to the returned column. Unfortunately, it's just a ruby Hash, with no type data attached. How can I turn this hash into Neo4j::Node objects ?

Am I barking up the wrong tree? Once I have a Neo4j::Server::CypherResponse::HashEnumeration, what else can I do with it?

Label.find_nodes doesn't find nodes found by other query methods

Maybe I'm doing this wrong, but I've performed a set of queries in a number of different ways and Label.find_nodes is not returning some expected results:

[21] pry(main)> n= Neo4j::Label.find_nodes(:changeset, :committer, "Ray Goodwin").to_a.map {|x| x[:tfs_id]}
=> [3998, 3999, ..., 3794]

# Looking for the node with TFS ID 3998 (second result)

n= Neo4j::Label.find_nodes(:changeset, :tfs_id, 3998).to_a
=> []
# Not found?? orly...

n= Neo4j::Label.query(:changeset, conditions: {tfs_id: 3998}).to_a
=> [CypherNode 270 (8910)]

n[:tfs_id]
=> 3998
# found!!

n= Neo4j::Label.query(:changeset, conditions: {tfs_id: 3998}).to_a.first.neo_id
=> 270

n= Neo4j::Node.load 270
=> CypherNode 270 (8858)
# The actual node

n[:tfs_id]
=> 3998

# also found!!

ServerException due to URL concatenation not happening properly in cypher_session.rb

I'm using neo4j-core 3.0.0.alpha.8 with MRI ruby 2.1.1p76

I have a model called User which has an index on a field like this:

  index :uid

When the rack application starts up and tries to require my model, this is what I see:

 /ruby/gems/ruby-2.1.1/gems/neo4j-core-3.0.0.alpha.8/lib/neo4j-server/resource.rb:38:in `handle_response_error': Expected response code 200 Error for request http://192.168.1.1:7474/db/dataschema/index/User, 404,  (Neo4j::Server::Resource::ServerException)
    from /ruby/gems/ruby-2.1.1/gems/neo4j-core-3.0.0.alpha.8/lib/neo4j-server/resource.rb:42:in `expect_response_code'
    from /ruby/gems/ruby-2.1.1/gems/neo4j-core-3.0.0.alpha.8/lib/neo4j-server/cypher_session.rb:80:in `indexes'
    from /ruby/gems/ruby-2.1.1/gems/neo4j-core-3.0.0.alpha.8/lib/neo4j-server/cypher_label.rb:25:in `indexes'
    from /ruby/gems/ruby-2.1.1/gems/neo4j-3.0.0.alpha.3/lib/neo4j/active_node/labels.rb:121:in `block in _index'
    from /ruby/gems/ruby-2.1.1/gems/neo4j-3.0.0.alpha.3/lib/neo4j/active_node/labels.rb:119:in `each'
    from /ruby/gems/ruby-2.1.1/gems/neo4j-3.0.0.alpha.3/lib/neo4j/active_node/labels.rb:119:in `_index'
    from /ruby/gems/ruby-2.1.1/gems/neo4j-3.0.0.alpha.3/lib/neo4j/active_node/labels.rb:89:in `index'
    from /my_project/models/user.rb:16:in `<class:User>'
    from /my_project/models/user.rb:1:in `<top (required)>'

Investigating into this a bit, this is the response I get when HTTParty.get(endpoint_url || 'http://localhost:7474') runs in cypher_session.rb at Line 5 :

{
  "management" : "http://192.168.1.1:7474/db/manage",
  "data" : "http://192.168.1.1:7474/db/data"
}

Now, when root_data['data'] gets used as @resource_url in line 79 of cypher_session.rb like this:

HTTParty.get("#{@resource_url}schema/index/#{label}")

The resulting URL which HTTParty requests turns out to be something like:

http://192.168.1.1:7474/db/dataschema/index/User

The / between data and schema is missing, and so the response is always a 404 from the server.

valid? fails on blank objects

I get the following error on blank objects

user = User.new
user.valid? # throws
# NoMethodError: undefined method `query_default_return' for nil:NilClass from ~/.rvm/gems/ruby-2.1.2/gems/neo4j-core-3.0.0.alpha.12/lib/neo4j/label.rb:68:in `query'

rake neo4j:install breaks when "wget" is not available

Running neo4j:install when wget isn't installed breaks the rake task and prints out the stack trace for the error like this:

ausmarton$ rake neo4j:install[community-2.0.2]
Installing Neo4j-community-2.0.2
rake aborted!
Errno::ENOENT: No such file or directory - wget
/Users/ausmarton/Projects/oss/neo4j-core/lib/neo4j/tasks/neo4j_server.rb:47:in ``'
/Users/ausmarton/Projects/oss/neo4j-core/lib/neo4j/tasks/neo4j_server.rb:47:in `block (2 levels) in <top (required)>'
/Users/ausmarton/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/Users/ausmarton/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => neo4j:install
(See full trace by running task with --trace)

Now, I know that wget is something you find on most *nix systems, but I was thinking it might be helpful to have some better way to notify users of a missing dependency.

Do we need to put in some checks for wget (and maybe other binaries that we need) or maybe some better error messaging around this?

mixing >> and > in cypher queries does not work

Neo4j::Cypher.new { start_node=node(1); end_node=node(2); r = rel(":friends"); p = start_node > r > node(:intermediate) >> end_node; r[:x]==42; p}.to_s
 => "START n0=node(1),n1=node(2) MATCH (intermediate)-->(n1),m4 = (n0)-[:friends]->(m4) WHERE v1.x = 42 RETURN m4"

Automatic convert cypher result to Neo4j::Node

Investigate if this is possible:

result = session.query("START n=node(*) RETURN n, n.name as name")
result.to_a[0][:n] # => Returns the Neo4j::Node or wrapped Neo4j::Node
result.to_a[0][:name] # => Returns something else

We want that the user does not have to write the following workaround which returns the ID of each node (RETURN ID(n)) and then loading them. (The neo4j-core wrapper should do this for you.)

result = session.query("START n=node(*) RETURN ID(n) as id, n.name as name")
Neo4j::Node.load(result.to_a[0][:id])

This is a spike of #51

The problem is that if we do a START n=node(42) RETURN n then we will receive too much data from the server, some thing like this:

{"columns"=>["n"], "data"=>[[{"labels"=>"http://localhost:7474/db/data/node/4127/labels", "outgoing_relationships"=>"http://localhost:7474/db/data/node/4127/relationships/out", "data"=>{}, "traverse"=>"http://localhost:7474/db/data/node/4127/traverse/{returnType}", "all_typed_relationships"=>"http://localhost:7474/db/data/node/4127/relationships/al
...

This will make the queries run much slower. We would instead like neo4j-core to receive the node id of the node from the cypher HTTP endpoint and then load more data (e.g. properties etc...) if needed.

Neo4j.query ignores relationships

Query like this one

Neo4j.query(Actor.first){|a| m=node(:m); a > rel(Actor.roles) > m;m}

gives me:

START n0=node(3) MATCH (n0)-[]->(m) RETURN m

And should give:

START n0=node(3) MATCH (n0)-[Actor#role]->(m) RETURN m

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.