1

I am using neo4j version 3.X, I am using searchkick

currently using

User.search(params[:term], operator: 'or',
     fields: [:first_name, :last_name],
     misspellings: { below: 5 },
     match: :word_start,
    page: params[:page], per_page: params[:rpp], padding: params[:offset])

instead of

User.where('(sp.first_name + sp.last_name) =~ ?', /.*#{params[:term].sub(/\s/, '')}.*/i)

But I have problem where I have to make more cypher queries at the same time with searching How to do that?

For exmaple

Neo4j::ActiveBase.new_query.match(n: {User: { uuid: current_user.uuid }}).break
               .match('(n)-[:connected_to {status: 2}]-(sp:User)')
               .return('DISTINCT sp')

I want to seach in this query with elasctic search with first name & last name

In my model I have defined searchkick word_start: [:first_name, :last_name]

Vishal G
  • 1,521
  • 11
  • 30

1 Answers1

0

It's been a while since I've used searchkick, but I would suggest trying to use the ActiveNode syntax instead of the neo4j-core Query syntax so that you can append .search on the end:

current_user.connected_users.rel_where(status: 2).distinct.search(...)

This is assuming that there is a connected_users association which uses the connected_to relationship type. You may have another, similar, association in your User model but I didn't know what it was.

I'm not 100% sure if the distinct will work with the search or not, but you could perhaps drop the .distinct part and searchkick might return you a distinct set anyway.

Brian Underwood
  • 10,746
  • 1
  • 22
  • 34