load_balanced_tire 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +14 -0
- data/.travis.yml +29 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +760 -0
- data/Rakefile +78 -0
- data/examples/rails-application-template.rb +249 -0
- data/examples/tire-dsl.rb +876 -0
- data/lib/tire.rb +55 -0
- data/lib/tire/alias.rb +296 -0
- data/lib/tire/configuration.rb +30 -0
- data/lib/tire/dsl.rb +43 -0
- data/lib/tire/http/client.rb +62 -0
- data/lib/tire/http/clients/curb.rb +61 -0
- data/lib/tire/http/clients/faraday.rb +71 -0
- data/lib/tire/http/response.rb +27 -0
- data/lib/tire/index.rb +361 -0
- data/lib/tire/logger.rb +60 -0
- data/lib/tire/model/callbacks.rb +40 -0
- data/lib/tire/model/import.rb +26 -0
- data/lib/tire/model/indexing.rb +128 -0
- data/lib/tire/model/naming.rb +100 -0
- data/lib/tire/model/percolate.rb +99 -0
- data/lib/tire/model/persistence.rb +71 -0
- data/lib/tire/model/persistence/attributes.rb +143 -0
- data/lib/tire/model/persistence/finders.rb +66 -0
- data/lib/tire/model/persistence/storage.rb +69 -0
- data/lib/tire/model/search.rb +307 -0
- data/lib/tire/results/collection.rb +114 -0
- data/lib/tire/results/item.rb +86 -0
- data/lib/tire/results/pagination.rb +54 -0
- data/lib/tire/rubyext/hash.rb +8 -0
- data/lib/tire/rubyext/ruby_1_8.rb +7 -0
- data/lib/tire/rubyext/symbol.rb +11 -0
- data/lib/tire/search.rb +188 -0
- data/lib/tire/search/facet.rb +74 -0
- data/lib/tire/search/filter.rb +28 -0
- data/lib/tire/search/highlight.rb +37 -0
- data/lib/tire/search/query.rb +186 -0
- data/lib/tire/search/scan.rb +114 -0
- data/lib/tire/search/script_field.rb +23 -0
- data/lib/tire/search/sort.rb +25 -0
- data/lib/tire/tasks.rb +135 -0
- data/lib/tire/utils.rb +17 -0
- data/lib/tire/version.rb +22 -0
- data/test/fixtures/articles/1.json +1 -0
- data/test/fixtures/articles/2.json +1 -0
- data/test/fixtures/articles/3.json +1 -0
- data/test/fixtures/articles/4.json +1 -0
- data/test/fixtures/articles/5.json +1 -0
- data/test/integration/active_model_indexing_test.rb +51 -0
- data/test/integration/active_model_searchable_test.rb +114 -0
- data/test/integration/active_record_searchable_test.rb +446 -0
- data/test/integration/boolean_queries_test.rb +43 -0
- data/test/integration/count_test.rb +34 -0
- data/test/integration/custom_score_queries_test.rb +88 -0
- data/test/integration/dis_max_queries_test.rb +68 -0
- data/test/integration/dsl_search_test.rb +22 -0
- data/test/integration/explanation_test.rb +44 -0
- data/test/integration/facets_test.rb +259 -0
- data/test/integration/filtered_queries_test.rb +66 -0
- data/test/integration/filters_test.rb +63 -0
- data/test/integration/fuzzy_queries_test.rb +20 -0
- data/test/integration/highlight_test.rb +64 -0
- data/test/integration/index_aliases_test.rb +122 -0
- data/test/integration/index_mapping_test.rb +43 -0
- data/test/integration/index_store_test.rb +96 -0
- data/test/integration/index_update_document_test.rb +111 -0
- data/test/integration/mongoid_searchable_test.rb +309 -0
- data/test/integration/percolator_test.rb +111 -0
- data/test/integration/persistent_model_test.rb +130 -0
- data/test/integration/prefix_query_test.rb +43 -0
- data/test/integration/query_return_version_test.rb +70 -0
- data/test/integration/query_string_test.rb +52 -0
- data/test/integration/range_queries_test.rb +36 -0
- data/test/integration/reindex_test.rb +46 -0
- data/test/integration/results_test.rb +39 -0
- data/test/integration/scan_test.rb +56 -0
- data/test/integration/script_fields_test.rb +38 -0
- data/test/integration/sort_test.rb +36 -0
- data/test/integration/text_query_test.rb +39 -0
- data/test/models/active_model_article.rb +31 -0
- data/test/models/active_model_article_with_callbacks.rb +49 -0
- data/test/models/active_model_article_with_custom_document_type.rb +7 -0
- data/test/models/active_model_article_with_custom_index_name.rb +7 -0
- data/test/models/active_record_models.rb +122 -0
- data/test/models/article.rb +15 -0
- data/test/models/mongoid_models.rb +97 -0
- data/test/models/persistent_article.rb +11 -0
- data/test/models/persistent_article_in_namespace.rb +12 -0
- data/test/models/persistent_article_with_casting.rb +28 -0
- data/test/models/persistent_article_with_defaults.rb +11 -0
- data/test/models/persistent_articles_with_custom_index_name.rb +10 -0
- data/test/models/supermodel_article.rb +17 -0
- data/test/models/validated_model.rb +11 -0
- data/test/test_helper.rb +93 -0
- data/test/unit/active_model_lint_test.rb +17 -0
- data/test/unit/configuration_test.rb +74 -0
- data/test/unit/http_client_test.rb +76 -0
- data/test/unit/http_response_test.rb +49 -0
- data/test/unit/index_alias_test.rb +275 -0
- data/test/unit/index_test.rb +894 -0
- data/test/unit/logger_test.rb +125 -0
- data/test/unit/model_callbacks_test.rb +116 -0
- data/test/unit/model_import_test.rb +71 -0
- data/test/unit/model_persistence_test.rb +528 -0
- data/test/unit/model_search_test.rb +913 -0
- data/test/unit/results_collection_test.rb +281 -0
- data/test/unit/results_item_test.rb +162 -0
- data/test/unit/rubyext_test.rb +66 -0
- data/test/unit/search_facet_test.rb +153 -0
- data/test/unit/search_filter_test.rb +42 -0
- data/test/unit/search_highlight_test.rb +46 -0
- data/test/unit/search_query_test.rb +301 -0
- data/test/unit/search_scan_test.rb +113 -0
- data/test/unit/search_script_field_test.rb +26 -0
- data/test/unit/search_sort_test.rb +50 -0
- data/test/unit/search_test.rb +499 -0
- data/test/unit/tire_test.rb +126 -0
- data/tire.gemspec +90 -0
- metadata +549 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class PersistentModelIntegrationTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
PersistentArticle.index.delete
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
super
|
15
|
+
PersistentArticle.index.delete
|
16
|
+
PersistentArticleWithDefaults.index.delete
|
17
|
+
end
|
18
|
+
|
19
|
+
context "PersistentModel" do
|
20
|
+
should "search with simple query" do
|
21
|
+
PersistentArticle.create :id => 1, :title => 'One'
|
22
|
+
PersistentArticle.index.refresh
|
23
|
+
|
24
|
+
results = PersistentArticle.search 'one'
|
25
|
+
assert_equal 'One', results.first.title
|
26
|
+
end
|
27
|
+
|
28
|
+
should "search with a block" do
|
29
|
+
PersistentArticle.create :id => 1, :title => 'One'
|
30
|
+
PersistentArticle.index.refresh
|
31
|
+
|
32
|
+
results = PersistentArticle.search(:sort => 'title') { query { string 'one' } }
|
33
|
+
assert_equal 'One', results.first.title
|
34
|
+
end
|
35
|
+
|
36
|
+
should "return instances of model" do
|
37
|
+
PersistentArticle.create :id => 1, :title => 'One'
|
38
|
+
PersistentArticle.index.refresh
|
39
|
+
|
40
|
+
results = PersistentArticle.search 'one'
|
41
|
+
assert_instance_of PersistentArticle, results.first
|
42
|
+
end
|
43
|
+
|
44
|
+
should "save documents into index and find them by IDs" do
|
45
|
+
one = PersistentArticle.create :id => 1, :title => 'One'
|
46
|
+
two = PersistentArticle.create :id => 2, :title => 'Two'
|
47
|
+
|
48
|
+
PersistentArticle.index.refresh
|
49
|
+
|
50
|
+
results = PersistentArticle.find [1, 2]
|
51
|
+
|
52
|
+
assert_equal 2, results.size
|
53
|
+
end
|
54
|
+
|
55
|
+
should "be persisted" do
|
56
|
+
one = PersistentArticle.create :id => 1, :title => 'One'
|
57
|
+
PersistentArticle.index.refresh
|
58
|
+
|
59
|
+
a = PersistentArticle.all.first
|
60
|
+
assert a.persisted?, a.inspect
|
61
|
+
|
62
|
+
b = PersistentArticle.first
|
63
|
+
assert b.persisted?, b.inspect
|
64
|
+
|
65
|
+
c = PersistentArticle.search { query { string 'one' } }.first
|
66
|
+
assert c.persisted?, c.inspect
|
67
|
+
end
|
68
|
+
|
69
|
+
should "return default values for properties without value" do
|
70
|
+
PersistentArticleWithDefaults.create :id => 1, :title => 'One'
|
71
|
+
PersistentArticleWithDefaults.index.refresh
|
72
|
+
|
73
|
+
results = PersistentArticleWithDefaults.all
|
74
|
+
|
75
|
+
assert_equal [], results.first.tags
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with pagination" do
|
79
|
+
|
80
|
+
setup do
|
81
|
+
1.upto(9) { |number| PersistentArticle.create :title => "Test#{number}" }
|
82
|
+
PersistentArticle.index.refresh
|
83
|
+
end
|
84
|
+
|
85
|
+
should "find first page with five results" do
|
86
|
+
results = PersistentArticle.search( :per_page => 5, :page => 1 ) { query { all } }
|
87
|
+
assert_equal 5, results.size
|
88
|
+
|
89
|
+
# WillPaginate
|
90
|
+
#
|
91
|
+
assert_equal 2, results.total_pages
|
92
|
+
assert_equal 1, results.current_page
|
93
|
+
assert_equal nil, results.previous_page
|
94
|
+
assert_equal 2, results.next_page
|
95
|
+
|
96
|
+
# Kaminari
|
97
|
+
#
|
98
|
+
assert_equal 5, results.limit_value
|
99
|
+
assert_equal 9, results.total_count
|
100
|
+
assert_equal 2, results.num_pages
|
101
|
+
assert_equal 0, results.offset_value
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
context "with namespaced models" do
|
107
|
+
setup do
|
108
|
+
MyNamespace::PersistentArticleInNamespace.create :title => 'Test'
|
109
|
+
MyNamespace::PersistentArticleInNamespace.index.refresh
|
110
|
+
end
|
111
|
+
|
112
|
+
teardown do
|
113
|
+
MyNamespace::PersistentArticleInNamespace.index.delete
|
114
|
+
end
|
115
|
+
|
116
|
+
should "find the document in the index" do
|
117
|
+
results = MyNamespace::PersistentArticleInNamespace.search 'test'
|
118
|
+
|
119
|
+
assert results.any?, "No results returned: #{results.inspect}"
|
120
|
+
assert_equal 1, results.count
|
121
|
+
|
122
|
+
assert_instance_of MyNamespace::PersistentArticleInNamespace, results.first
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class PrefixQueryTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
context "Prefix queries" do
|
9
|
+
|
10
|
+
should "search by a prefix" do
|
11
|
+
s = Tire.search('articles-test') do
|
12
|
+
query do
|
13
|
+
# "on" => "One"
|
14
|
+
prefix :title, "on"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
assert_equal 1, s.results.size
|
19
|
+
assert_equal ['One'], s.results.map(&:title)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "allow to specify boost" do
|
23
|
+
s = Tire.search('articles-test') do
|
24
|
+
query do
|
25
|
+
boolean do
|
26
|
+
# "on" => "One", boost it
|
27
|
+
should { prefix :title, "on", :boost => 2.0 }
|
28
|
+
should { all }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
sort { by :_score }
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_equal 5, s.results.size
|
35
|
+
assert_equal 'One', s.results.first.title
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class DslVersionIntegrationTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
context "DSL Version" do
|
9
|
+
|
10
|
+
setup do
|
11
|
+
Tire.index 'articles-test-ids' do
|
12
|
+
delete
|
13
|
+
create
|
14
|
+
|
15
|
+
store :id => 1, :title => 'One'
|
16
|
+
store :id => 2, :title => 'Two'
|
17
|
+
|
18
|
+
refresh
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
teardown { Tire.index('articles-test-ids').delete }
|
23
|
+
|
24
|
+
should "returns actual version (non-nil) value for records when 'version' is true" do
|
25
|
+
s = Tire.search('articles-test-ids') do
|
26
|
+
version true
|
27
|
+
query { string 'One' }
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal 1, s.results.count
|
31
|
+
|
32
|
+
document = s.results.first
|
33
|
+
assert_equal 'One', document.title
|
34
|
+
assert_equal 1, document._version.to_i
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
should "returns a nil version field when 'version' is false" do
|
39
|
+
s = Tire.search('articles-test-ids') do
|
40
|
+
version false
|
41
|
+
query { string 'One' }
|
42
|
+
end
|
43
|
+
|
44
|
+
assert_equal 1, s.results.count
|
45
|
+
|
46
|
+
document = s.results.first
|
47
|
+
assert_equal 'One', document.title
|
48
|
+
assert_nil document._version
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
should "returns a nil version field when 'version' is not included" do
|
53
|
+
s = Tire.search('articles-test-ids') do
|
54
|
+
query { string 'One' }
|
55
|
+
end
|
56
|
+
|
57
|
+
assert_equal 1, s.results.count
|
58
|
+
|
59
|
+
document = s.results.first
|
60
|
+
assert_equal 'One', document.title
|
61
|
+
assert_nil document._version
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class QueryStringIntegrationTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
context "Searching for query string" do
|
9
|
+
|
10
|
+
should "find article by title" do
|
11
|
+
q = 'title:one'
|
12
|
+
assert_equal 1, string_query(q).results.count
|
13
|
+
assert_equal 'One', string_query(q).results.first[:title]
|
14
|
+
end
|
15
|
+
|
16
|
+
should "find articles by title with boosting" do
|
17
|
+
q = 'title:one^100 OR title:two'
|
18
|
+
assert_equal 2, string_query(q).results.count
|
19
|
+
assert_equal 'One', string_query(q).results.first[:title]
|
20
|
+
end
|
21
|
+
|
22
|
+
should "find articles by tags" do
|
23
|
+
q = 'tags:ruby AND tags:python'
|
24
|
+
assert_equal 1, string_query(q).results.count
|
25
|
+
assert_equal 'Two', string_query(q).results.first[:title]
|
26
|
+
end
|
27
|
+
|
28
|
+
should "find any article with tags" do
|
29
|
+
q = 'tags:ruby OR tags:python OR tags:java'
|
30
|
+
assert_equal 4, string_query(q).results.count
|
31
|
+
end
|
32
|
+
|
33
|
+
should "pass options to query definition" do
|
34
|
+
s = Tire.search 'articles-test' do
|
35
|
+
query do
|
36
|
+
string 'ruby python', :default_operator => 'AND'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
assert_equal 1, s.results.count
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def string_query(q)
|
47
|
+
Tire.search('articles-test') { query { string q } }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class RangeQueriesIntegrationTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
context "Range queries" do
|
9
|
+
|
10
|
+
should "allow simple range queries" do
|
11
|
+
s = Tire.search('articles-test') do
|
12
|
+
query do
|
13
|
+
range :words, { :gte => 250 }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
assert_equal 3, s.results.size
|
18
|
+
assert_equal ['Two', 'Three', 'Four'].sort, s.results.map(&:title).sort
|
19
|
+
end
|
20
|
+
|
21
|
+
should "allow combined range queries" do
|
22
|
+
s = Tire.search('articles-test') do
|
23
|
+
query do
|
24
|
+
range :words, { :gte => 250, :lt => 375 }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
assert_equal 2, s.results.size
|
29
|
+
assert_equal ['Two', 'Four'].sort, s.results.map(&:title).sort
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class ReindexIntegrationTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
context "Reindex" do
|
9
|
+
setup do
|
10
|
+
Tire.index('reindex-test-new').delete
|
11
|
+
|
12
|
+
documents = (1..100).map { |i| { id: i, type: 'test', title: "Document #{i}" } }
|
13
|
+
|
14
|
+
Tire.index 'reindex-test' do
|
15
|
+
delete
|
16
|
+
create :settings => { :number_of_shards => 1, :number_of_replicas => 0 }
|
17
|
+
import documents
|
18
|
+
refresh
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
teardown do
|
23
|
+
Index.new('reindex-test').delete
|
24
|
+
Index.new('reindex-test-new').delete
|
25
|
+
end
|
26
|
+
|
27
|
+
should "reindex the index into a new index with different settings" do
|
28
|
+
Tire.index('reindex-test').reindex 'reindex-test-new', settings: { number_of_shards: 3 }
|
29
|
+
|
30
|
+
Tire.index('reindex-test-new').refresh
|
31
|
+
assert_equal 100, Tire.search('reindex-test-new').results.total
|
32
|
+
assert_equal '3', Tire.index('reindex-test-new').settings['index.number_of_shards']
|
33
|
+
end
|
34
|
+
|
35
|
+
should "reindex a portion of an index into a new index" do
|
36
|
+
Tire.index('reindex-test').reindex('reindex-test-new') { query { string '10*' } }
|
37
|
+
|
38
|
+
Tire.index('reindex-test-new').refresh
|
39
|
+
assert_equal 2, Tire.search('reindex-test-new').results.total
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class ResultsIntegrationTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
context "Query results" do
|
9
|
+
|
10
|
+
should "allow easy access to returned documents" do
|
11
|
+
q = 'title:one'
|
12
|
+
s = Tire.search('articles-test') { query { string q } }
|
13
|
+
assert_equal 'One', s.results.first.title
|
14
|
+
assert_equal 'ruby', s.results.first.tags[0]
|
15
|
+
end
|
16
|
+
|
17
|
+
should "allow easy access to returned documents with limited fields" do
|
18
|
+
q = 'title:one'
|
19
|
+
s = Tire.search('articles-test') { query { string q }.fields :title }
|
20
|
+
assert_equal 'One', s.results.first.title
|
21
|
+
assert_nil s.results.first.tags
|
22
|
+
end
|
23
|
+
|
24
|
+
should "allow to retrieve multiple fields" do
|
25
|
+
q = 'title:one'
|
26
|
+
s = Tire.search('articles-test') do
|
27
|
+
query { string q }
|
28
|
+
fields 'title', 'tags'
|
29
|
+
end
|
30
|
+
assert_equal 'One', s.results.first.title
|
31
|
+
assert_equal 'ruby', s.results.first.tags[0]
|
32
|
+
assert_nil s.results.first.published_on
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tire
|
4
|
+
|
5
|
+
class ScanIntegrationTest < Test::Unit::TestCase
|
6
|
+
include Test::Integration
|
7
|
+
|
8
|
+
context "Scan" do
|
9
|
+
setup do
|
10
|
+
documents = (1..100).map { |i| { id: i, type: 'test', title: "Document #{i}" } }
|
11
|
+
|
12
|
+
Tire.index 'scantest' do
|
13
|
+
delete
|
14
|
+
create :settings => { :number_of_shards => 1, :number_of_replicas => 0 }
|
15
|
+
import documents
|
16
|
+
refresh
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
teardown { Index.new('scantest').delete }
|
21
|
+
|
22
|
+
should "iterate over batches of documents" do
|
23
|
+
count = 0
|
24
|
+
|
25
|
+
s = Tire.scan 'scantest'
|
26
|
+
s.each { |results| count += 1 }
|
27
|
+
|
28
|
+
assert_equal 10, count
|
29
|
+
end
|
30
|
+
|
31
|
+
should "iterate over individual documents" do
|
32
|
+
count = 0
|
33
|
+
|
34
|
+
s = Tire.scan 'scantest'
|
35
|
+
s.each_document { |results| count += 1 }
|
36
|
+
|
37
|
+
assert_equal 100, count
|
38
|
+
end
|
39
|
+
|
40
|
+
should "limit the returned results by query" do
|
41
|
+
count = 0
|
42
|
+
|
43
|
+
s = Tire.scan('scantest') { query { string '10*' } }
|
44
|
+
s.each do |results|
|
45
|
+
count += 1
|
46
|
+
assert_equal ['Document 10', 'Document 100'], results.map(&:title)
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_equal 1, count
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|