gummi 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,6 +29,17 @@ module Gummi
29
29
  nil
30
30
  end
31
31
 
32
+ def delete_children_by_query(parent_id, children_query)
33
+ parent_id_query = { term: { _parent: parent_id } }
34
+ query = { bool: { must: [parent_id_query, children_query] } }
35
+ delete_by_query query
36
+ end
37
+
38
+ def delete_by_query(query)
39
+ options = { index: index.name, type: document_type, body: query }
40
+ Hashie::Mash.new client.delete_by_query options
41
+ end
42
+
32
43
  # –––––––––––––––––––––
33
44
  # Public Conversion API
34
45
  # –––––––––––––––––––––
@@ -4,13 +4,14 @@ module Gummi
4
4
  module Search
5
5
  class Result
6
6
 
7
- attr_reader :took, :total, :hits
7
+ attr_reader :took, :total, :hits, :facets
8
8
 
9
9
  def initialize(response, converter, per_page, page)
10
10
  @response = Hashie::Mash.new response
11
11
  @took = @response.hits.took
12
12
  @total = @response.hits.total
13
13
  @hits = @response.hits.hits
14
+ @facets = @response.facets
14
15
  @converter = converter
15
16
  @per_page = per_page
16
17
  @page = page
@@ -13,10 +13,13 @@ module Gummi
13
13
  end
14
14
 
15
15
  def facets
16
+ return unless search_result.facets
16
17
  @facets ||= begin
17
- response.facets.each_with_object({}) do |(name, content), facets|
18
- facets[name] = Hash[content.terms.map(&:values)]
18
+ result = {}
19
+ search_result.facets.each do |(name, content)|
20
+ result[name] = Hash[content.terms.map(&:values)]
19
21
  end
22
+ Hashie::Mash.new result
20
23
  end
21
24
  end
22
25
 
@@ -1,3 +1,3 @@
1
1
  module Gummi
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -120,5 +120,20 @@ describe Gummi::DbLayer::Document do
120
120
  end
121
121
  end
122
122
 
123
+ describe '#delete_children_by_query' do
124
+ before do
125
+ DB::Rating.get(rating.id, person.id)
126
+ Gummi::DbLayer::DefaultIndex.refresh
127
+ end
128
+
129
+ it 'deletes children by a query' do
130
+ DB::Rating.get(rating.id, person.id).should be_true
131
+ DB::Rating.delete_children_by_query(person.id, term: { stars: 3 }).should be_true
132
+ DB::Rating.get(rating.id, person.id).should be_true
133
+ DB::Rating.delete_children_by_query(person.id, term: { stars: 5 }).should be_true
134
+ DB::Rating.get(rating.id, person.id).should be_nil
135
+ end
136
+ end
137
+
123
138
  end
124
139
  end
@@ -45,8 +45,10 @@ describe Gummi::RepositoryLayer::Repository do
45
45
  it 'finds the correct documents' do
46
46
  result = People.search do |search|
47
47
  search.query_string = 'Woody'
48
+ search.facets[:names] = { terms: { field: :name, all_terms: true, size: 100 } }
48
49
  end
49
50
  result.total.should == 1
51
+ result.facets.names.woody.should == 1
50
52
  result.records.first.name.should == 'Woody'
51
53
  end
52
54
 
@@ -55,6 +57,7 @@ describe Gummi::RepositoryLayer::Repository do
55
57
  search.query_string = 'Woody'
56
58
  end
57
59
  woody = result.records.first
60
+ result.facets.should be_nil
58
61
  woody.converted_name.should == 'ydooW'
59
62
  woody.should be_a Person
60
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gummi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: