Skip to content

Commit

Permalink
a few more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Nov 13, 2012
1 parent d72d0f6 commit 1676918
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions neo_crunch.rb
Expand Up @@ -153,17 +153,14 @@ def create_graph
neo = Neography::Rest.new

puts "Creating Indexes"
neo.create_node_index("company_index", "fulltext", "lucene")
neo.create_node_index("people_index", "fulltext", "lucene")
neo.create_node_index("fo_index", "fulltext", "lucene")
neo.create_node_index("tag_index", "fulltext", "lucene")
neo.create_node_index("node_index", "fulltext", "lucene")

puts "Creating Company Nodes"
company_nodes = {}
companies.each_slice(100) do |slice|
commands = []
slice.each_with_index do |company, index|
commands << [:create_unique_node, "company_index", "permalink", company[:permalink], company]
commands << [:create_unique_node, "node_index", "permalink", company[:permalink], company]
end

batch_results = neo.batch *commands
Expand All @@ -177,7 +174,7 @@ def create_graph
people.each_slice(100) do |slice|
commands = []
slice.each_with_index do |person, index|
commands << [:create_unique_node, "people_index", "permalink", person[:permalink],person]
commands << [:create_unique_node, "node_index", "permalink", person[:permalink],person]
end

batch_results = neo.batch *commands
Expand All @@ -192,7 +189,7 @@ def create_graph
fos.each_slice(100) do |slice|
commands = []
slice.each_with_index do |fo, index|
commands << [:create_unique_node, "fo_index", "permalink", fo[:permalink], fo]
commands << [:create_unique_node, "node_index", "permalink", fo[:permalink], fo]
end

batch_results = neo.batch *commands
Expand All @@ -207,7 +204,7 @@ def create_graph
tags.each_slice(100) do |slice|
commands = []
slice.each_with_index do |tag, index|
commands << [:create_unique_node, "tag_index", "name", tag[:name], tag]
commands << [:create_unique_node, "node_index", "name", tag[:name], tag]
end

batch_results = neo.batch *commands
Expand Down Expand Up @@ -336,12 +333,12 @@ def get_properties(node)
content_type :json
neo = Neography::Rest.new

cypher = "START me=node:company_index({query})
cypher = "START me=node:node_index({query})
RETURN ID(me), me.name
ORDER BY me.name
LIMIT 15"

neo.execute_query(cypher, {:query => "permalink:*#{params[:term]}*" })["data"].map{|x| { label: x[1], value: x[0]}}.to_json
neo.execute_query(cypher, {:query => "permalink:*#{params[:term]}* OR name:*#{params[:term]}*" })["data"].map{|x| { label: x[1], value: x[0]}}.to_json
end

get '/best' do
Expand Down

0 comments on commit 1676918

Please sign in to comment.