riddle 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.travis.yml +16 -0
- data/Gemfile +6 -0
- data/HISTORY +45 -0
- data/LICENCE +20 -0
- data/README.textile +5 -3
- data/Rakefile +23 -0
- data/lib/riddle.rb +1 -0
- data/lib/riddle/0.9.9/configuration/searchd.rb +10 -8
- data/lib/riddle/auto_version.rb +2 -2
- data/lib/riddle/client.rb +117 -118
- data/lib/riddle/configuration.rb +6 -6
- data/lib/riddle/configuration/distributed_index.rb +16 -16
- data/lib/riddle/configuration/sql_source.rb +5 -5
- data/lib/riddle/controller.rb +28 -25
- data/lib/riddle/query.rb +31 -20
- data/lib/riddle/query/select.rb +69 -8
- data/lib/riddle/version.rb +3 -0
- data/riddle.gemspec +25 -0
- data/spec/fixtures/.gitignore +2 -0
- data/spec/fixtures/data/0.9.9/anchor.bin +0 -0
- data/spec/fixtures/data/0.9.9/any.bin +0 -0
- data/spec/fixtures/data/0.9.9/boolean.bin +0 -0
- data/spec/fixtures/data/0.9.9/comment.bin +0 -0
- data/spec/fixtures/data/0.9.9/distinct.bin +0 -0
- data/spec/fixtures/data/0.9.9/field_weights.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter_array.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter_array_exclude.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter_boolean.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter_floats.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter_floats_exclude.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter_range.bin +0 -0
- data/spec/fixtures/data/0.9.9/filter_range_exclude.bin +0 -0
- data/spec/fixtures/data/0.9.9/group.bin +0 -0
- data/spec/fixtures/data/0.9.9/index.bin +0 -0
- data/spec/fixtures/data/0.9.9/index_weights.bin +0 -0
- data/spec/fixtures/data/0.9.9/keywords_with_hits.bin +0 -0
- data/spec/fixtures/data/0.9.9/keywords_without_hits.bin +0 -0
- data/spec/fixtures/data/0.9.9/overrides.bin +0 -0
- data/spec/fixtures/data/0.9.9/phrase.bin +0 -0
- data/spec/fixtures/data/0.9.9/rank_mode.bin +0 -0
- data/spec/fixtures/data/0.9.9/select.bin +0 -0
- data/spec/fixtures/data/0.9.9/simple.bin +0 -0
- data/spec/fixtures/data/0.9.9/sort.bin +0 -0
- data/spec/fixtures/data/0.9.9/update_simple.bin +0 -0
- data/spec/fixtures/data/0.9.9/weights.bin +0 -0
- data/spec/fixtures/data/1.10/anchor.bin +0 -0
- data/spec/fixtures/data/1.10/any.bin +0 -0
- data/spec/fixtures/data/1.10/boolean.bin +0 -0
- data/spec/fixtures/data/1.10/comment.bin +0 -0
- data/spec/fixtures/data/1.10/distinct.bin +0 -0
- data/spec/fixtures/data/1.10/field_weights.bin +0 -0
- data/spec/fixtures/data/1.10/filter.bin +0 -0
- data/spec/fixtures/data/1.10/filter_array.bin +0 -0
- data/spec/fixtures/data/1.10/filter_array_exclude.bin +0 -0
- data/spec/fixtures/data/1.10/filter_boolean.bin +0 -0
- data/spec/fixtures/data/1.10/filter_floats.bin +0 -0
- data/spec/fixtures/data/1.10/filter_floats_exclude.bin +0 -0
- data/spec/fixtures/data/1.10/filter_range.bin +0 -0
- data/spec/fixtures/data/1.10/filter_range_exclude.bin +0 -0
- data/spec/fixtures/data/1.10/group.bin +0 -0
- data/spec/fixtures/data/1.10/index.bin +0 -0
- data/spec/fixtures/data/1.10/index_weights.bin +0 -0
- data/spec/fixtures/data/1.10/keywords_with_hits.bin +0 -0
- data/spec/fixtures/data/1.10/keywords_without_hits.bin +0 -0
- data/spec/fixtures/data/1.10/overrides.bin +0 -0
- data/spec/fixtures/data/1.10/phrase.bin +0 -0
- data/spec/fixtures/data/1.10/rank_mode.bin +0 -0
- data/spec/fixtures/data/1.10/select.bin +0 -0
- data/spec/fixtures/data/1.10/simple.bin +0 -0
- data/spec/fixtures/data/1.10/sort.bin +0 -0
- data/spec/fixtures/data/1.10/update_simple.bin +0 -0
- data/spec/fixtures/data/1.10/weights.bin +0 -0
- data/spec/fixtures/data/2.0.1/anchor.bin +0 -0
- data/spec/fixtures/data/2.0.1/any.bin +0 -0
- data/spec/fixtures/data/2.0.1/boolean.bin +0 -0
- data/spec/fixtures/data/2.0.1/comment.bin +0 -0
- data/spec/fixtures/data/2.0.1/distinct.bin +0 -0
- data/spec/fixtures/data/2.0.1/field_weights.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter_array.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter_array_exclude.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter_boolean.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter_floats.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter_floats_exclude.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter_range.bin +0 -0
- data/spec/fixtures/data/2.0.1/filter_range_exclude.bin +0 -0
- data/spec/fixtures/data/2.0.1/group.bin +0 -0
- data/spec/fixtures/data/2.0.1/index.bin +0 -0
- data/spec/fixtures/data/2.0.1/index_weights.bin +0 -0
- data/spec/fixtures/data/2.0.1/keywords_with_hits.bin +0 -0
- data/spec/fixtures/data/2.0.1/keywords_without_hits.bin +0 -0
- data/spec/fixtures/data/2.0.1/overrides.bin +0 -0
- data/spec/fixtures/data/2.0.1/phrase.bin +0 -0
- data/spec/fixtures/data/2.0.1/rank_mode.bin +0 -0
- data/spec/fixtures/data/2.0.1/select.bin +0 -0
- data/spec/fixtures/data/2.0.1/simple.bin +0 -0
- data/spec/fixtures/data/2.0.1/sort.bin +0 -0
- data/spec/fixtures/data/2.0.1/update_simple.bin +0 -0
- data/spec/fixtures/data/2.0.1/weights.bin +0 -0
- data/spec/fixtures/data_generator.0.9.8.php +208 -0
- data/spec/fixtures/data_generator.0.9.9.php +5 -0
- data/spec/fixtures/data_generator.1.10.php +5 -0
- data/spec/fixtures/data_generator.2.0.1.php +5 -0
- data/spec/fixtures/data_generator.php +223 -0
- data/spec/fixtures/sphinxapi.0.9.8.php +1228 -0
- data/spec/fixtures/sphinxapi.0.9.9.php +1646 -0
- data/spec/fixtures/sphinxapi.1.10.php +1728 -0
- data/spec/fixtures/sphinxapi.2.0.1.php +1731 -0
- data/spec/fixtures/sql/conf.example.yml +3 -0
- data/spec/fixtures/sql/data.sql +25000 -0
- data/spec/fixtures/sql/data.tsv +25000 -0
- data/spec/fixtures/sql/structure.sql +16 -0
- data/spec/functional/connection_spec.rb +10 -12
- data/spec/functional/excerpt_spec.rb +1 -1
- data/spec/functional/keywords_spec.rb +1 -1
- data/spec/functional/persistance_spec.rb +1 -1
- data/spec/functional/search_spec.rb +1 -1
- data/spec/functional/status_spec.rb +1 -1
- data/spec/functional/update_spec.rb +1 -1
- data/spec/riddle/auto_version_spec.rb +18 -10
- data/spec/riddle/query/select_spec.rb +78 -14
- data/spec/riddle/query_spec.rb +5 -3
- data/spec/spec_helper.rb +13 -15
- data/spec/support/binary_fixtures.rb +18 -0
- data/spec/support/sphinx.rb +135 -0
- data/spec/unit/client_spec.rb +150 -142
- data/spec/unit/configuration/distributed_index_spec.rb +15 -15
- data/spec/unit/configuration/searchd_spec.rb +28 -3
- data/spec/unit/configuration_spec.rb +6 -6
- metadata +254 -68
- data/spec/sphinx_helper.rb +0 -96
data/riddle.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'riddle/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'riddle'
|
7
|
+
s.version = Riddle::Version
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Pat Allan']
|
10
|
+
s.email = ['pat@freelancing-gods.com']
|
11
|
+
s.homepage = 'http://freelancing-god.github.com/riddle/'
|
12
|
+
s.summary = %q{An API for Sphinx, written in and for Ruby.}
|
13
|
+
s.description = %q{A Ruby API and configuration helper for the Sphinx search service.}
|
14
|
+
|
15
|
+
s.rubyforge_project = 'riddle'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ['lib']
|
21
|
+
|
22
|
+
s.add_development_dependency 'rake', '>= 0.9.2'
|
23
|
+
s.add_development_dependency 'rspec', '>= 2.5.0'
|
24
|
+
s.add_development_dependency 'yard', '>= 0.7.2'
|
25
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,208 @@
|
|
1
|
+
<?php
|
2
|
+
include 'sphinxapi.0.9.8.php';
|
3
|
+
|
4
|
+
$client = new SphinxClient();
|
5
|
+
$client->SetServer("localhost", 3312);
|
6
|
+
|
7
|
+
// simple
|
8
|
+
$file = fopen("spec/fixtures/data/simple.bin", "w");
|
9
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
10
|
+
fclose($file);
|
11
|
+
|
12
|
+
// index
|
13
|
+
$file = fopen("spec/fixtures/data/index.bin", "w");
|
14
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ", "edition")]);
|
15
|
+
fclose($file);
|
16
|
+
|
17
|
+
// any
|
18
|
+
$client->SetMatchMode(SPH_MATCH_ANY);
|
19
|
+
|
20
|
+
$file = fopen("spec/fixtures/data/any.bin", "w");
|
21
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test this ")]);
|
22
|
+
fclose($file);
|
23
|
+
|
24
|
+
$client->SetMatchMode(SPH_MATCH_ALL);
|
25
|
+
|
26
|
+
// sort
|
27
|
+
$client->SetSortMode(SPH_SORT_EXTENDED, "id");
|
28
|
+
|
29
|
+
$file = fopen("spec/fixtures/data/sort.bin", "w");
|
30
|
+
fwrite($file, $client->_reqs[$client->AddQuery("testing ")]);
|
31
|
+
fclose($file);
|
32
|
+
|
33
|
+
$client->SetSortMode(SPH_SORT_RELEVANCE, "");
|
34
|
+
|
35
|
+
// boolean
|
36
|
+
$client->SetMatchMode(SPH_MATCH_BOOLEAN);
|
37
|
+
|
38
|
+
$file = fopen("spec/fixtures/data/boolean.bin", "w");
|
39
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
40
|
+
fclose($file);
|
41
|
+
|
42
|
+
$client->SetMatchMode(SPH_MATCH_ALL);
|
43
|
+
|
44
|
+
// phrase
|
45
|
+
$client->SetMatchMode(SPH_MATCH_PHRASE);
|
46
|
+
|
47
|
+
$file = fopen("spec/fixtures/data/phrase.bin", "w");
|
48
|
+
fwrite($file, $client->_reqs[$client->AddQuery("testing this ")]);
|
49
|
+
fclose($file);
|
50
|
+
|
51
|
+
$client->SetMatchMode(SPH_MATCH_ALL);
|
52
|
+
|
53
|
+
// filter
|
54
|
+
$client->SetFilter("id", array(10, 100, 1000));
|
55
|
+
|
56
|
+
$file = fopen("spec/fixtures/data/filter.bin", "w");
|
57
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
58
|
+
fclose($file);
|
59
|
+
|
60
|
+
$client->ResetFilters();
|
61
|
+
|
62
|
+
// group
|
63
|
+
$client->SetGroupBy("id", SPH_GROUPBY_ATTR, "id");
|
64
|
+
|
65
|
+
$file = fopen("spec/fixtures/data/group.bin", "w");
|
66
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
67
|
+
fclose($file);
|
68
|
+
|
69
|
+
$client->ResetGroupBy();
|
70
|
+
|
71
|
+
// distinct
|
72
|
+
$client->SetGroupDistinct("id");
|
73
|
+
|
74
|
+
$file = fopen("spec/fixtures/data/distinct.bin", "w");
|
75
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
76
|
+
fclose($file);
|
77
|
+
|
78
|
+
$client->ResetGroupBy();
|
79
|
+
|
80
|
+
// weights
|
81
|
+
$client->SetWeights(array(100, 1));
|
82
|
+
|
83
|
+
$file = fopen("spec/fixtures/data/weights.bin", "w");
|
84
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
85
|
+
fclose($file);
|
86
|
+
|
87
|
+
$client->SetWeights(array());
|
88
|
+
|
89
|
+
// anchor
|
90
|
+
$client->SetGeoAnchor("latitude", "longitude", 10.0, 95.0);
|
91
|
+
|
92
|
+
$file = fopen("spec/fixtures/data/anchor.bin", "w");
|
93
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
94
|
+
fclose($file);
|
95
|
+
|
96
|
+
$client->ResetFilters();
|
97
|
+
|
98
|
+
// rank_mode
|
99
|
+
$client->SetRankingMode(SPH_RANK_WORDCOUNT);
|
100
|
+
|
101
|
+
$file = fopen("spec/fixtures/data/rank_mode.bin", "w");
|
102
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
103
|
+
fclose($file);
|
104
|
+
|
105
|
+
$client->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
|
106
|
+
|
107
|
+
// index_weights
|
108
|
+
$client->SetIndexWeights(array("people" => 101));
|
109
|
+
|
110
|
+
$file = fopen("spec/fixtures/data/index_weights.bin", "w");
|
111
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
112
|
+
fclose($file);
|
113
|
+
|
114
|
+
$client->SetIndexWeights(array());
|
115
|
+
|
116
|
+
// index_weights
|
117
|
+
$client->SetFieldWeights(array("city" => 101));
|
118
|
+
|
119
|
+
$file = fopen("spec/fixtures/data/field_weights.bin", "w");
|
120
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
121
|
+
fclose($file);
|
122
|
+
|
123
|
+
$client->SetFieldWeights(array());
|
124
|
+
|
125
|
+
// comment
|
126
|
+
$file = fopen("spec/fixtures/data/comment.bin", "w");
|
127
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ", "*", "commenting")]);
|
128
|
+
fclose($file);
|
129
|
+
|
130
|
+
// update_simple
|
131
|
+
$file = fopen("spec/fixtures/data/update_simple.bin", "w");
|
132
|
+
fwrite($file, $client->UpdateAttributes("people", array("birthday"), array(1 => array(191163600))));
|
133
|
+
fclose($file);
|
134
|
+
|
135
|
+
// keywords_without_hits
|
136
|
+
$file = fopen("spec/fixtures/data/keywords_without_hits.bin", "w");
|
137
|
+
fwrite($file, $client->BuildKeywords("pat", "people", false));
|
138
|
+
fclose($file);
|
139
|
+
|
140
|
+
// keywords_with_hits
|
141
|
+
$file = fopen("spec/fixtures/data/keywords_with_hits.bin", "w");
|
142
|
+
fwrite($file, $client->BuildKeywords("pat", "people", true));
|
143
|
+
fclose($file);
|
144
|
+
|
145
|
+
// filter_array
|
146
|
+
$client->SetFilter("field", array(1, 2, 3));
|
147
|
+
|
148
|
+
$file = fopen("spec/fixtures/data/filter_array.bin", "w");
|
149
|
+
fwrite($file, $client->FilterOutput());
|
150
|
+
fclose($file);
|
151
|
+
|
152
|
+
$client->ResetFilters();
|
153
|
+
|
154
|
+
// filter_array_exclude
|
155
|
+
$client->SetFilter("field", array(1, 2, 3), true);
|
156
|
+
|
157
|
+
$file = fopen("spec/fixtures/data/filter_array_exclude.bin", "w");
|
158
|
+
fwrite($file, $client->FilterOutput());
|
159
|
+
fclose($file);
|
160
|
+
|
161
|
+
$client->ResetFilters();
|
162
|
+
|
163
|
+
// filter_range
|
164
|
+
$client->SetFilterRange("field", 1, 3);
|
165
|
+
|
166
|
+
$file = fopen("spec/fixtures/data/filter_range.bin", "w");
|
167
|
+
fwrite($file, $client->FilterOutput());
|
168
|
+
fclose($file);
|
169
|
+
|
170
|
+
$client->ResetFilters();
|
171
|
+
|
172
|
+
// filter_range_exclude
|
173
|
+
$client->SetFilterRange("field", 1, 3, true);
|
174
|
+
|
175
|
+
$file = fopen("spec/fixtures/data/filter_range_exclude.bin", "w");
|
176
|
+
fwrite($file, $client->FilterOutput());
|
177
|
+
fclose($file);
|
178
|
+
|
179
|
+
$client->ResetFilters();
|
180
|
+
|
181
|
+
// filter_floats
|
182
|
+
$client->SetFilterFloatRange("field", 5.4, 13.5);
|
183
|
+
|
184
|
+
$file = fopen("spec/fixtures/data/filter_floats.bin", "w");
|
185
|
+
fwrite($file, $client->FilterOutput());
|
186
|
+
fclose($file);
|
187
|
+
|
188
|
+
$client->ResetFilters();
|
189
|
+
|
190
|
+
// filter_floats_exclude
|
191
|
+
$client->SetFilterFloatRange("field", 5.4, 13.5, true);
|
192
|
+
|
193
|
+
$file = fopen("spec/fixtures/data/filter_floats_exclude.bin", "w");
|
194
|
+
fwrite($file, $client->FilterOutput());
|
195
|
+
fclose($file);
|
196
|
+
|
197
|
+
$client->ResetFilters();
|
198
|
+
|
199
|
+
// filter_boolean
|
200
|
+
$client->SetFilter("field", array(0, 1));
|
201
|
+
|
202
|
+
$file = fopen("spec/fixtures/data/filter_boolean.bin", "w");
|
203
|
+
fwrite($file, $client->FilterOutput());
|
204
|
+
fclose($file);
|
205
|
+
|
206
|
+
$client->ResetFilters();
|
207
|
+
|
208
|
+
?>
|
@@ -0,0 +1,223 @@
|
|
1
|
+
<?php
|
2
|
+
$client = new SphinxClient();
|
3
|
+
$client->SetServer("localhost", 3312);
|
4
|
+
|
5
|
+
// simple
|
6
|
+
$file = fopen("spec/fixtures/data/$version/simple.bin", "w");
|
7
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
8
|
+
fclose($file);
|
9
|
+
|
10
|
+
// index
|
11
|
+
$file = fopen("spec/fixtures/data/$version/index.bin", "w");
|
12
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ", "edition")]);
|
13
|
+
fclose($file);
|
14
|
+
|
15
|
+
// any
|
16
|
+
$client->SetMatchMode(SPH_MATCH_ANY);
|
17
|
+
|
18
|
+
$file = fopen("spec/fixtures/data/$version/any.bin", "w");
|
19
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test this ")]);
|
20
|
+
fclose($file);
|
21
|
+
|
22
|
+
$client->SetMatchMode(SPH_MATCH_ALL);
|
23
|
+
|
24
|
+
// sort
|
25
|
+
$client->SetSortMode(SPH_SORT_EXTENDED, "id");
|
26
|
+
|
27
|
+
$file = fopen("spec/fixtures/data/$version/sort.bin", "w");
|
28
|
+
fwrite($file, $client->_reqs[$client->AddQuery("testing ")]);
|
29
|
+
fclose($file);
|
30
|
+
|
31
|
+
$client->SetSortMode(SPH_SORT_RELEVANCE, "");
|
32
|
+
|
33
|
+
// boolean
|
34
|
+
$client->SetMatchMode(SPH_MATCH_BOOLEAN);
|
35
|
+
|
36
|
+
$file = fopen("spec/fixtures/data/$version/boolean.bin", "w");
|
37
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
38
|
+
fclose($file);
|
39
|
+
|
40
|
+
$client->SetMatchMode(SPH_MATCH_ALL);
|
41
|
+
|
42
|
+
// phrase
|
43
|
+
$client->SetMatchMode(SPH_MATCH_PHRASE);
|
44
|
+
|
45
|
+
$file = fopen("spec/fixtures/data/$version/phrase.bin", "w");
|
46
|
+
fwrite($file, $client->_reqs[$client->AddQuery("testing this ")]);
|
47
|
+
fclose($file);
|
48
|
+
|
49
|
+
$client->SetMatchMode(SPH_MATCH_ALL);
|
50
|
+
|
51
|
+
// filter
|
52
|
+
$client->SetFilter("id", array(10, 100, 1000));
|
53
|
+
|
54
|
+
$file = fopen("spec/fixtures/data/$version/filter.bin", "w");
|
55
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
56
|
+
fclose($file);
|
57
|
+
|
58
|
+
$client->ResetFilters();
|
59
|
+
|
60
|
+
// group
|
61
|
+
$client->SetGroupBy("id", SPH_GROUPBY_ATTR, "id");
|
62
|
+
|
63
|
+
$file = fopen("spec/fixtures/data/$version/group.bin", "w");
|
64
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
65
|
+
fclose($file);
|
66
|
+
|
67
|
+
$client->ResetGroupBy();
|
68
|
+
|
69
|
+
// distinct
|
70
|
+
$client->SetGroupDistinct("id");
|
71
|
+
|
72
|
+
$file = fopen("spec/fixtures/data/$version/distinct.bin", "w");
|
73
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
74
|
+
fclose($file);
|
75
|
+
|
76
|
+
$client->ResetGroupBy();
|
77
|
+
|
78
|
+
// weights
|
79
|
+
$client->SetWeights(array(100, 1));
|
80
|
+
|
81
|
+
$file = fopen("spec/fixtures/data/$version/weights.bin", "w");
|
82
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
83
|
+
fclose($file);
|
84
|
+
|
85
|
+
$client->SetWeights(array());
|
86
|
+
|
87
|
+
// anchor
|
88
|
+
$client->SetGeoAnchor("latitude", "longitude", 10.0, 95.0);
|
89
|
+
|
90
|
+
$file = fopen("spec/fixtures/data/$version/anchor.bin", "w");
|
91
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
92
|
+
fclose($file);
|
93
|
+
|
94
|
+
$client->ResetFilters();
|
95
|
+
|
96
|
+
// rank_mode
|
97
|
+
$client->SetRankingMode(SPH_RANK_WORDCOUNT);
|
98
|
+
|
99
|
+
$file = fopen("spec/fixtures/data/$version/rank_mode.bin", "w");
|
100
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
101
|
+
fclose($file);
|
102
|
+
|
103
|
+
$client->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
|
104
|
+
|
105
|
+
// index_weights
|
106
|
+
$client->SetIndexWeights(array("people" => 101));
|
107
|
+
|
108
|
+
$file = fopen("spec/fixtures/data/$version/index_weights.bin", "w");
|
109
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
110
|
+
fclose($file);
|
111
|
+
|
112
|
+
$client->SetIndexWeights(array());
|
113
|
+
|
114
|
+
// index_weights
|
115
|
+
$client->SetFieldWeights(array("city" => 101));
|
116
|
+
|
117
|
+
$file = fopen("spec/fixtures/data/$version/field_weights.bin", "w");
|
118
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
119
|
+
fclose($file);
|
120
|
+
|
121
|
+
$client->SetFieldWeights(array());
|
122
|
+
|
123
|
+
// comment
|
124
|
+
$file = fopen("spec/fixtures/data/$version/comment.bin", "w");
|
125
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ", "*", "commenting")]);
|
126
|
+
fclose($file);
|
127
|
+
|
128
|
+
// update_simple
|
129
|
+
$file = fopen("spec/fixtures/data/$version/update_simple.bin", "w");
|
130
|
+
fwrite($file, $client->UpdateAttributes("people", array("birthday"), array(1 => array(191163600))));
|
131
|
+
fclose($file);
|
132
|
+
|
133
|
+
// keywords_without_hits
|
134
|
+
$file = fopen("spec/fixtures/data/$version/keywords_without_hits.bin", "w");
|
135
|
+
fwrite($file, $client->BuildKeywords("pat", "people", false));
|
136
|
+
fclose($file);
|
137
|
+
|
138
|
+
// keywords_with_hits
|
139
|
+
$file = fopen("spec/fixtures/data/$version/keywords_with_hits.bin", "w");
|
140
|
+
fwrite($file, $client->BuildKeywords("pat", "people", true));
|
141
|
+
fclose($file);
|
142
|
+
|
143
|
+
// overrides
|
144
|
+
$client->SetOverride("rating", SPH_ATTR_FLOAT, array(1 => 10.0));
|
145
|
+
|
146
|
+
$file = fopen("spec/fixtures/data/$version/overrides.bin", "w");
|
147
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
148
|
+
fclose($file);
|
149
|
+
|
150
|
+
$client->ResetOverrides();
|
151
|
+
|
152
|
+
// select
|
153
|
+
$client->SetSelect("selecting");
|
154
|
+
|
155
|
+
$file = fopen("spec/fixtures/data/$version/select.bin", "w");
|
156
|
+
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
|
157
|
+
fclose($file);
|
158
|
+
|
159
|
+
$client->SetSelect("*");
|
160
|
+
|
161
|
+
// filter_array
|
162
|
+
$client->SetFilter("field", array(1, 2, 3));
|
163
|
+
|
164
|
+
$file = fopen("spec/fixtures/data/$version/filter_array.bin", "w");
|
165
|
+
fwrite($file, $client->FilterOutput());
|
166
|
+
fclose($file);
|
167
|
+
|
168
|
+
$client->ResetFilters();
|
169
|
+
|
170
|
+
// filter_array_exclude
|
171
|
+
$client->SetFilter("field", array(1, 2, 3), true);
|
172
|
+
|
173
|
+
$file = fopen("spec/fixtures/data/$version/filter_array_exclude.bin", "w");
|
174
|
+
fwrite($file, $client->FilterOutput());
|
175
|
+
fclose($file);
|
176
|
+
|
177
|
+
$client->ResetFilters();
|
178
|
+
|
179
|
+
// filter_range
|
180
|
+
$client->SetFilterRange("field", 1, 3);
|
181
|
+
|
182
|
+
$file = fopen("spec/fixtures/data/$version/filter_range.bin", "w");
|
183
|
+
fwrite($file, $client->FilterOutput());
|
184
|
+
fclose($file);
|
185
|
+
|
186
|
+
$client->ResetFilters();
|
187
|
+
|
188
|
+
// filter_range_exclude
|
189
|
+
$client->SetFilterRange("field", 1, 3, true);
|
190
|
+
|
191
|
+
$file = fopen("spec/fixtures/data/$version/filter_range_exclude.bin", "w");
|
192
|
+
fwrite($file, $client->FilterOutput());
|
193
|
+
fclose($file);
|
194
|
+
|
195
|
+
$client->ResetFilters();
|
196
|
+
|
197
|
+
// filter_floats
|
198
|
+
$client->SetFilterFloatRange("field", 5.4, 13.5);
|
199
|
+
|
200
|
+
$file = fopen("spec/fixtures/data/$version/filter_floats.bin", "w");
|
201
|
+
fwrite($file, $client->FilterOutput());
|
202
|
+
fclose($file);
|
203
|
+
|
204
|
+
$client->ResetFilters();
|
205
|
+
|
206
|
+
// filter_floats_exclude
|
207
|
+
$client->SetFilterFloatRange("field", 5.4, 13.5, true);
|
208
|
+
|
209
|
+
$file = fopen("spec/fixtures/data/$version/filter_floats_exclude.bin", "w");
|
210
|
+
fwrite($file, $client->FilterOutput());
|
211
|
+
fclose($file);
|
212
|
+
|
213
|
+
$client->ResetFilters();
|
214
|
+
|
215
|
+
// filter_boolean
|
216
|
+
$client->SetFilter("field", array(0, 1));
|
217
|
+
|
218
|
+
$file = fopen("spec/fixtures/data/$version/filter_boolean.bin", "w");
|
219
|
+
fwrite($file, $client->FilterOutput());
|
220
|
+
fclose($file);
|
221
|
+
|
222
|
+
$client->ResetFilters();
|
223
|
+
?>
|