rifle 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  class SearchesController < ApplicationController
2
2
 
3
+ def flush
4
+ Rifle.flush
5
+ render json: {status: 'success'}, status: :ok
6
+ end
7
+
3
8
  def store
4
9
  urn = params[:urn]
5
10
  payload = JSON.parse(request.body.read)
@@ -7,6 +7,15 @@ require_relative 'rifle/rifle_resque'
7
7
  require_relative 'rifle/rifle_client'
8
8
 
9
9
  module Rifle
10
+ def self.flush
11
+ p "Flushing all Rifle indices..."
12
+ keys = Rifle.settings.redis.keys("rifle:*")
13
+ keys.each { |k|
14
+ Rifle.settings.redis.del(k)
15
+ }
16
+ p "Flushing all Rifle indices complete"
17
+ end
18
+
10
19
  def self.store(urn, hash)
11
20
  Processor.new.index_resource(urn, hash)
12
21
  end
@@ -18,6 +27,7 @@ module Rifle
18
27
  class Processor
19
28
 
20
29
  def index_resource(urn, hash)
30
+ p "Rifle indexing object with urn #{urn}"
21
31
  # First get the old values
22
32
  old_payload = get_payload_for_urn(urn)
23
33
  if old_payload
@@ -47,6 +57,7 @@ module Rifle
47
57
  end
48
58
 
49
59
  def search_for(sentence, urns_only)
60
+ p "Rifle searching for #{sentence}, urns only #{urns_only}"
50
61
  words = get_words_array_from_text(sentence)
51
62
  metaphones = get_metaphones_from_word_set(Set.new(words))
52
63
  urns = Set.new
@@ -54,6 +65,7 @@ module Rifle
54
65
  new_urns = get_urns_for_metaphone(metaphone)
55
66
  urns = urns.merge(new_urns)
56
67
  end
68
+ p "Rifle found #{urns.size} urns"
57
69
  if urns_only
58
70
  urns
59
71
  else
@@ -1,5 +1,12 @@
1
1
  module Rifle
2
2
  module Client
3
+ def self.flush
4
+ if Rifle.settings.use_rest_server
5
+ RestClient.post("#{Rifle.settings.use_rest_server}/flush")
6
+ else
7
+ Rifle.flush
8
+ end
9
+ end
3
10
  def self.store(urn, json)
4
11
  if (json.is_a? Hash)
5
12
  json = json.to_json
@@ -1,3 +1,3 @@
1
1
  module Rifle
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rifle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000 Z
12
+ date: 2012-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails