2

I am using Neo4j.rb and searchkick for a ruby on rails app.

I have the following class

class NeoUser 
  include Neo4j::ActiveNode

  searchkick

  property :first_name, type: String
  property :last_name, type: String
  property :email, type: String

  has_many :out, :neo_users, rel_class: Following

end

In the rails console i do:

 NeoUser.reindex

and then :

result = NeoUser.search "*"

I get an empty array back : i.e result.size gives me 0

I do have data in my Neo4j database running on localhost:7000

I have my elasticsearch server up and running on localhost:9200

NeoUser.find_by() does give me correct results, so i am unable to figure out why the searchkick search function fails.

Any ideas?

EDIT :

Output of NeoUser.reindex:

 CYPHER 36ms MATCH (n:`NeoUser`) RETURN n ORDER BY n.uuid LIMIT   {limit_1000} | {:limit_1000=>1000}
 => true 

VERSIONS

neo4j (5.2.9)

neo4j-core (5.1.6)

elasticsearch (1.0.13)

elasticsearch-api (1.0.13)

elasticsearch-transport (1.0.13)

searchkick (0.9.1)

Has it got something to do with the fact that i have installed elasticsearch version 1.7.2 in my ubuntu machine?

EDIT 2 :

I saw that when i create data using the console, the search function is able to return the data.

So i guess searchkick is unable to access my original neo4j database running in my localhost:9200.

but NeoUser.all does return all my data nodes, so how do i tell searchkick to use that specific database, or is there some other issue?

Artemis Fowl
  • 301
  • 1
  • 10
  • Hrmmm, maybe... I'm using elasticsearch 1.6.0 which I installed via Homebrew. Going to see if I can update... – Brian Underwood Oct 14 '15 at 08:51
  • Just updated to 1.7.2 and not having any issues... Could you maybe try using it with ActiveRecord to see if it's a problem with searchkick or with neo4j.rb? – Brian Underwood Oct 14 '15 at 08:58

2 Answers2

0

That's really strange. I'm trying to reproduce locally but it's working for me. What are your versions of neo4j/neo4j-core/searchkick?

One suggestion is that you might try putting your searchkick line below the properties in case it needs to see them to search.

Also, what sort of output do you see when you do NeoUser.reindex? How many NeoUser nodes do you have?

Brian Underwood
  • 10,746
  • 1
  • 22
  • 34
  • I have edited the question, and NeoUser.reindex does not show me number of nodes (which is 18 by the way (just testing right now)). – Artemis Fowl Oct 14 '15 at 08:12
  • Gotcha. That looks fine to me. I just wanted to make sure the `find_in_batches` that elasticsearch was calling in the gem was working. – Brian Underwood Oct 14 '15 at 08:49
  • It works fine with ActiveRecord sqlite, so i guess the problem is with neo4j.rb – Artemis Fowl Oct 14 '15 at 10:01
  • I saw that when i create data using the console, the search function is able to return the data. So i guess searchkick is unable to access my original neo4j database running in my localhost server. – Artemis Fowl Oct 14 '15 at 10:13
  • `searchkick` should be using the right database based on the model that you put it on. Did you try moving the call to `searchkick` lower? Maybe also try calling `searchkick index_name: 'foobarindex'` and `reindex` again to refresh things.... – Brian Underwood Oct 14 '15 at 12:32
  • Oh, I misunderstood your comment. So maybe there's a problem with the `reindex`. My suggestion in the last comment might help then. How many times did you try to `reindex`? – Brian Underwood Oct 14 '15 at 12:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92282/discussion-between-artemis-fowl-and-brian-underwood). – Artemis Fowl Oct 14 '15 at 15:09
0

I had this same issue, and it turns out that the I was getting zero results with a 3 character search, but if I input 5 characters I would get results. I assume this is a default ES configuration. Maybe this will save someone some time.

trueinViso
  • 1,354
  • 3
  • 18
  • 30