Hi
Sort only works with lucene queries, exampels
https://github.com/andreasronge/neo4j/blob/master/spec/rails/finders_spec.rb
The all method use neo traversals.
Try use an index and wildcard query instead.
Regarding scope, what do you want to find ?
sent from my phone
--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To view this discussion on the web visit https://groups.google.com/d/msg/neo4jrb/-/iZ0rW0zaWIAJ.
To post to this group, send email to neo...@googlegroups.com.
To unsubscribe from this group, send email to neo4jrb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
What do you mean running 1.6 community? No server is needed.
sent from my phone
--
On Tue, Jan 24, 2012 at 6:04 AM, Peter Ehrlich
<peter.i...@gmail.com> wrote:
> Hm. Sever turned off and it still works, like you say. ok!
>
> Got the lucene sort going, thanks. Some new questions though:
>
> - A node must be indexed to be search. How can an index be rebuilt, to
> include already existing nodes?
If you already have data that you don't want to lose then have a look
at migrations -
http://neo4j.rubyforge.org/guides/migrations.html#add-index
>
> - I want to pass in a hash, and have a node and relationship made.
> Normally one would use accepts_nested_attributes_for, but this does not
> allow control over the more complicated case of
> find_or_create_by(:location_id => '123'). I tried to put my own handling in
> a before filter, but no callback seems to fire before "add_incoming_rel"
> does. I could alias_method_chain the #create method to handle it, but that
> seems just silly. Perhaps the only way is to pass in fully fledged
> locations?
Not sure I understand. You want a callback for adding/deleting relationships ?
Maybe a callback for the relationship would help.
Create your own relationship class instead of using the default
Neo4j::Rails::Relationship class.
E.g:
class MyRel < Neo4j::Rails::Relationship
before_create :do_stuff
def do_stuff
puts "start_node #{start_node.attributes.inspect}"
puts "end_node #{end_node.attributes.inspect}"
end
end
class Person
has_n(:friends).relationship(MyRel)
end
Cheers
Andreas
>
> Thanks,
> --Peter
>
> --
> You received this message because you are subscribed to the Google Groups
> "neo4jrb" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/neo4jrb/-/7Be5gbRPM1QJ.
# This allows anything to be thrown at a relationship and understood.# usage:## has_one(:location).to(Location)# accepts_hash_for :location## Will run Location.new with the passed in :location hash.# You can also give it a block which returns a location node:## accepts_hash_for :location do |location_attributes|# Location.find_or_create_by(:name => location_attributes[:name])# endI also created an easy serializer, here: https://gist.github.com/1674551I really like being able to throw any thing at a model, without so much as a second thought.Any practicality in looking to include these in neo4j proper, with a little work? (I don't know how indexing works, but how easy would it be to index on serialized properties, like mongoid?)A couple side questions:The migration docs seem out of date. They call for this, although MigrationMixin can't be found there:
classPersoninclude Neo4j::NodeMixin# does also work for Neo4j::Rails::Modelinclude Neo4j::MigrationMixinI fixed it like so, but haven't updated the docs, not knowing if my fix is a hack:class Goal < Neo4j::Rails::Modelinclude Neo4j::Migrations::NodeMixinCheers
--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To view this discussion on the web visit https://groups.google.com/d/msg/neo4jrb/-/NR6NUBxvjBcJ.