riddle 0.9.8.1112 → 0.9.8.1198
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/README +17 -4
- data/lib/riddle.rb +4 -2
- data/lib/riddle/client.rb +51 -12
- data/spec/functional/keywords_spec.rb +40 -0
- data/spec/unit/client_spec.rb +26 -0
- metadata +3 -61
- data/spec/fixtures/data/anchor.bin +0 -0
- data/spec/fixtures/data/any.bin +0 -0
- data/spec/fixtures/data/boolean.bin +0 -0
- data/spec/fixtures/data/distinct.bin +0 -0
- data/spec/fixtures/data/field_weights.bin +0 -0
- data/spec/fixtures/data/filter.bin +0 -0
- data/spec/fixtures/data/filter_array.bin +0 -0
- data/spec/fixtures/data/filter_array_exclude.bin +0 -0
- data/spec/fixtures/data/filter_floats.bin +0 -0
- data/spec/fixtures/data/filter_floats_exclude.bin +0 -0
- data/spec/fixtures/data/filter_floats_range.bin +0 -0
- data/spec/fixtures/data/filter_range.bin +0 -0
- data/spec/fixtures/data/filter_range_exclude.bin +0 -0
- data/spec/fixtures/data/group.bin +0 -0
- data/spec/fixtures/data/index.bin +0 -0
- data/spec/fixtures/data/index_weights.bin +0 -0
- data/spec/fixtures/data/phrase.bin +0 -0
- data/spec/fixtures/data/rank_mode.bin +0 -0
- data/spec/fixtures/data/simple.bin +0 -0
- data/spec/fixtures/data/sort.bin +0 -0
- data/spec/fixtures/data/update_simple.bin +0 -0
- data/spec/fixtures/data/weights.bin +0 -0
- data/spec/fixtures/data_generator.php +0 -130
- data/spec/fixtures/sphinx/configuration.erb +0 -38
- data/spec/fixtures/sphinx/people.old.spa +0 -0
- data/spec/fixtures/sphinx/people.old.spd +0 -0
- data/spec/fixtures/sphinx/people.old.sph +0 -0
- data/spec/fixtures/sphinx/people.old.spi +0 -0
- data/spec/fixtures/sphinx/people.old.spm +0 -0
- data/spec/fixtures/sphinx/people.old.spp +0 -0
- data/spec/fixtures/sphinx/people.spa +0 -0
- data/spec/fixtures/sphinx/people.spd +0 -0
- data/spec/fixtures/sphinx/people.sph +0 -0
- data/spec/fixtures/sphinx/people.spi +0 -0
- data/spec/fixtures/sphinx/people.spm +0 -0
- data/spec/fixtures/sphinx/people.spp +0 -0
- data/spec/fixtures/sphinx/searchd.log +0 -4732
- data/spec/fixtures/sphinx/searchd.query.log +0 -783
- data/spec/fixtures/sphinx/spec.conf +0 -38
- data/spec/fixtures/sphinxapi.php +0 -1066
- data/spec/fixtures/sql/conf.example.yml +0 -3
- data/spec/fixtures/sql/conf.yml +0 -3
- data/spec/fixtures/sql/data.sql +0 -25000
- data/spec/fixtures/sql/structure.sql +0 -16
- data/spec/spec_helper.rb +0 -26
- data/spec/sphinx_helper.rb +0 -92
data/README
CHANGED
|
@@ -5,16 +5,27 @@ client and the original PHP client - credit where credit's due, after all.
|
|
|
5
5
|
It does not follow the same syntax as those two, though (not much point writing this otherwise) -
|
|
6
6
|
opting for a more Ruby-like structure.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The easiest way to install is to grab the gem (available since 0.9.8r1112 only):
|
|
9
|
+
|
|
10
|
+
sudo gem install riddle
|
|
11
|
+
|
|
12
|
+
However, if you're so inclined, you can grab sourcecode via subversion. If you
|
|
9
13
|
are after a specific release, use the tag as follows:
|
|
10
14
|
|
|
11
|
-
svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/tags/0.9.8-
|
|
15
|
+
svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/tags/0.9.8-rc1 riddle
|
|
12
16
|
|
|
13
17
|
Or for the most current, just use trunk:
|
|
14
18
|
|
|
15
19
|
svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/trunk riddle
|
|
16
20
|
|
|
17
|
-
Please note that at the time of writing,
|
|
21
|
+
Please note that at the time of writing, the following versions are supported (if you get the appropriate tag):
|
|
22
|
+
|
|
23
|
+
* 0.9.8-r871
|
|
24
|
+
* 0.9.8-r909
|
|
25
|
+
* 0.9.8-r985
|
|
26
|
+
* 0.9.8-r1065
|
|
27
|
+
* 0.9.8-r1112
|
|
28
|
+
* 0.9.8-rc1 (gem version is 0.9.8.1198)
|
|
18
29
|
|
|
19
30
|
To get started, just instantiate a Client object:
|
|
20
31
|
|
|
@@ -57,4 +68,6 @@ total number of matches (which may be greater than the maximum available), and t
|
|
|
57
68
|
that the query took to run.
|
|
58
69
|
|
|
59
70
|
<tt>:status</tt> is the error code for the query - and if there was a related warning, it will be under
|
|
60
|
-
the <tt>:warning</tt> key. Fatal errors will be described under <tt>:error</tt>.
|
|
71
|
+
the <tt>:warning</tt> key. Fatal errors will be described under <tt>:error</tt>.
|
|
72
|
+
|
|
73
|
+
If you've installed the gem and wondering why there's no tests - check out the svn version. I've kept the specs out of the gem as I have a decent amount of test data in there, which really isn't needed unless you want to submit patches.
|
data/lib/riddle.rb
CHANGED
|
@@ -12,9 +12,11 @@ module Riddle #:nodoc:
|
|
|
12
12
|
Major = 0
|
|
13
13
|
Minor = 9
|
|
14
14
|
Tiny = 8
|
|
15
|
-
|
|
15
|
+
# Revision number for RubyForge's sake, taken from what Sphinx
|
|
16
|
+
# outputs to the command line.
|
|
17
|
+
Rev = 1198
|
|
16
18
|
|
|
17
|
-
String = [Major, Minor, Tiny].join('.') + "
|
|
19
|
+
String = [Major, Minor, Tiny].join('.') + "rc1"
|
|
18
20
|
GemVersion = [Major, Minor, Tiny, Rev].join('.')
|
|
19
21
|
end
|
|
20
22
|
end
|
data/lib/riddle/client.rb
CHANGED
|
@@ -26,15 +26,17 @@ module Riddle
|
|
|
26
26
|
#
|
|
27
27
|
class Client
|
|
28
28
|
Commands = {
|
|
29
|
-
:search
|
|
30
|
-
:excerpt
|
|
31
|
-
:update
|
|
29
|
+
:search => 0, # SEARCHD_COMMAND_SEARCH
|
|
30
|
+
:excerpt => 1, # SEARCHD_COMMAND_EXCERPT
|
|
31
|
+
:update => 2, # SEARCHD_COMMAND_UPDATE
|
|
32
|
+
:keywords => 3 # SEARCHD_COMMAND_KEYWORDS
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
Versions = {
|
|
35
|
-
:search
|
|
36
|
-
:excerpt
|
|
37
|
-
:update
|
|
36
|
+
:search => 0x113, # VER_COMMAND_SEARCH
|
|
37
|
+
:excerpt => 0x100, # VER_COMMAND_EXCERPT
|
|
38
|
+
:update => 0x101, # VER_COMMAND_UPDATE
|
|
39
|
+
:keywords => 0x100 # VER_COMMAND_KEYWORDS
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
Statuses = {
|
|
@@ -50,7 +52,7 @@ module Riddle
|
|
|
50
52
|
:phrase => 2, # SPH_MATCH_PHRASE
|
|
51
53
|
:boolean => 3, # SPH_MATCH_BOOLEAN
|
|
52
54
|
:extended => 4, # SPH_MATCH_EXTENDED
|
|
53
|
-
:
|
|
55
|
+
:fullscan => 5, # SPH_MATCH_FULLSCAN
|
|
54
56
|
:extended2 => 6 # SPH_MATCH_EXTENDED2
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -158,8 +160,8 @@ module Riddle
|
|
|
158
160
|
|
|
159
161
|
# Append a query to the queue. This uses the same parameters as the query
|
|
160
162
|
# method.
|
|
161
|
-
def append_query(search, index = '*')
|
|
162
|
-
@queue << query_message(search, index)
|
|
163
|
+
def append_query(search, index = '*', comments = '')
|
|
164
|
+
@queue << query_message(search, index, comments)
|
|
163
165
|
end
|
|
164
166
|
|
|
165
167
|
# Run all the queries currently in the queue. This will return an array of
|
|
@@ -275,8 +277,8 @@ module Riddle
|
|
|
275
277
|
# related warning, it will be under the <tt>:warning</tt> key. Fatal errors
|
|
276
278
|
# will be described under <tt>:error</tt>.
|
|
277
279
|
#
|
|
278
|
-
def query(search, index = '*')
|
|
279
|
-
@queue << query_message(search, index)
|
|
280
|
+
def query(search, index = '*', comments = '')
|
|
281
|
+
@queue << query_message(search, index, comments)
|
|
280
282
|
self.run.first
|
|
281
283
|
end
|
|
282
284
|
|
|
@@ -358,6 +360,30 @@ module Riddle
|
|
|
358
360
|
response.next_int
|
|
359
361
|
end
|
|
360
362
|
|
|
363
|
+
# Generates a keyword list for a given query. Each keyword is represented
|
|
364
|
+
# by a hash, with keys :tokenised and :normalised. If return_hits is set to
|
|
365
|
+
# true it will also report on the number of hits and documents for each
|
|
366
|
+
# keyword (see :hits and :docs keys respectively).
|
|
367
|
+
def keywords(query, index, return_hits = false)
|
|
368
|
+
response = Response.new request(
|
|
369
|
+
:keywords,
|
|
370
|
+
keywords_message(query, index, return_hits)
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
(0...response.next_int).collect do
|
|
374
|
+
hash = {}
|
|
375
|
+
hash[:tokenised] = response.next
|
|
376
|
+
hash[:normalised] = response.next
|
|
377
|
+
|
|
378
|
+
if return_hits
|
|
379
|
+
hash[:docs] = response.next_int
|
|
380
|
+
hash[:hits] = response.next_int
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
hash
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
361
387
|
private
|
|
362
388
|
|
|
363
389
|
# Connects to the Sphinx daemon, and yields a socket to use. The socket is
|
|
@@ -439,7 +465,7 @@ module Riddle
|
|
|
439
465
|
end
|
|
440
466
|
|
|
441
467
|
# Generation of the message to send to Sphinx for a search.
|
|
442
|
-
def query_message(search, index)
|
|
468
|
+
def query_message(search, index, comments = '')
|
|
443
469
|
message = Message.new
|
|
444
470
|
|
|
445
471
|
# Mode, Limits, Sort Mode
|
|
@@ -500,6 +526,8 @@ module Riddle
|
|
|
500
526
|
message.append_int val
|
|
501
527
|
end
|
|
502
528
|
|
|
529
|
+
message.append_string comments
|
|
530
|
+
|
|
503
531
|
message.to_s
|
|
504
532
|
end
|
|
505
533
|
|
|
@@ -544,5 +572,16 @@ module Riddle
|
|
|
544
572
|
|
|
545
573
|
message.to_s
|
|
546
574
|
end
|
|
575
|
+
|
|
576
|
+
# Generates the simple message to send to the daemon for a keywords request.
|
|
577
|
+
def keywords_message(query, index, return_hits)
|
|
578
|
+
message = Message.new
|
|
579
|
+
|
|
580
|
+
message.append_string query
|
|
581
|
+
message.append_string index
|
|
582
|
+
message.append_int return_hits ? 1 : 0
|
|
583
|
+
|
|
584
|
+
message.to_s
|
|
585
|
+
end
|
|
547
586
|
end
|
|
548
587
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Sphinx Keywords" do
|
|
4
|
+
before :each do
|
|
5
|
+
@client = Riddle::Client.new("localhost", 3313)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should return an array of hashes" do
|
|
9
|
+
results = @client.keywords("pat", "people")
|
|
10
|
+
results.should be_kind_of(Array)
|
|
11
|
+
|
|
12
|
+
results.each do |result|
|
|
13
|
+
result.should be_kind_of(Hash)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should have keys for normalised and tokenised versions of the keywords" do
|
|
18
|
+
results = @client.keywords("pat", "people")
|
|
19
|
+
results.each do |result|
|
|
20
|
+
result.keys.should include(:normalised)
|
|
21
|
+
result.keys.should include(:tokenised)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "shouldn't have docs or hits keys if not requested" do
|
|
26
|
+
results = @client.keywords("pat", "people")
|
|
27
|
+
results.each do |result|
|
|
28
|
+
result.keys.should_not include(:docs)
|
|
29
|
+
result.keys.should_not include(:hits)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should have docs and hits keys if requested" do
|
|
34
|
+
results = @client.keywords("pat", "people", true)
|
|
35
|
+
results.each do |result|
|
|
36
|
+
result.keys.should include(:docs)
|
|
37
|
+
result.keys.should include(:hits)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/spec/unit/client_spec.rb
CHANGED
|
@@ -123,6 +123,12 @@ describe Riddle::Client do
|
|
|
123
123
|
client.queue.first.should == query_contents(:field_weights)
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
+
it "should build a message with acomment correctly" do
|
|
127
|
+
client = Riddle::Client.new
|
|
128
|
+
client.append_query "test ", "*", "commenting"
|
|
129
|
+
client.queue.first.should == query_contents(:comment)
|
|
130
|
+
end
|
|
131
|
+
|
|
126
132
|
it "should keep multiple messages in the queue" do
|
|
127
133
|
client = Riddle::Client.new
|
|
128
134
|
client.weights = [100, 1]
|
|
@@ -151,4 +157,24 @@ describe Riddle::Client do
|
|
|
151
157
|
{1 => [191163600]}
|
|
152
158
|
).should == query_contents(:update_simple)
|
|
153
159
|
end
|
|
160
|
+
|
|
161
|
+
it "should build a keywords request without hits correctly" do
|
|
162
|
+
client = Riddle::Client.new
|
|
163
|
+
client.send(
|
|
164
|
+
:keywords_message,
|
|
165
|
+
"pat",
|
|
166
|
+
"people",
|
|
167
|
+
false
|
|
168
|
+
).should == query_contents(:keywords_without_hits)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "should build a keywords request with hits correctly" do
|
|
172
|
+
client = Riddle::Client.new
|
|
173
|
+
client.send(
|
|
174
|
+
:keywords_message,
|
|
175
|
+
"pat",
|
|
176
|
+
"people",
|
|
177
|
+
true
|
|
178
|
+
).should == query_contents(:keywords_with_hits)
|
|
179
|
+
end
|
|
154
180
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: riddle
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.8.
|
|
4
|
+
version: 0.9.8.1198
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pat Allan
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-03-
|
|
12
|
+
date: 2008-03-21 00:00:00 +11:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -29,65 +29,6 @@ files:
|
|
|
29
29
|
- lib/riddle.rb
|
|
30
30
|
- MIT-LICENCE
|
|
31
31
|
- README
|
|
32
|
-
- spec/fixtures
|
|
33
|
-
- spec/fixtures/data
|
|
34
|
-
- spec/fixtures/data/anchor.bin
|
|
35
|
-
- spec/fixtures/data/any.bin
|
|
36
|
-
- spec/fixtures/data/boolean.bin
|
|
37
|
-
- spec/fixtures/data/distinct.bin
|
|
38
|
-
- spec/fixtures/data/field_weights.bin
|
|
39
|
-
- spec/fixtures/data/filter.bin
|
|
40
|
-
- spec/fixtures/data/filter_array.bin
|
|
41
|
-
- spec/fixtures/data/filter_array_exclude.bin
|
|
42
|
-
- spec/fixtures/data/filter_floats.bin
|
|
43
|
-
- spec/fixtures/data/filter_floats_exclude.bin
|
|
44
|
-
- spec/fixtures/data/filter_floats_range.bin
|
|
45
|
-
- spec/fixtures/data/filter_range.bin
|
|
46
|
-
- spec/fixtures/data/filter_range_exclude.bin
|
|
47
|
-
- spec/fixtures/data/group.bin
|
|
48
|
-
- spec/fixtures/data/index.bin
|
|
49
|
-
- spec/fixtures/data/index_weights.bin
|
|
50
|
-
- spec/fixtures/data/phrase.bin
|
|
51
|
-
- spec/fixtures/data/rank_mode.bin
|
|
52
|
-
- spec/fixtures/data/simple.bin
|
|
53
|
-
- spec/fixtures/data/sort.bin
|
|
54
|
-
- spec/fixtures/data/update_simple.bin
|
|
55
|
-
- spec/fixtures/data/weights.bin
|
|
56
|
-
- spec/fixtures/data_generator.php
|
|
57
|
-
- spec/fixtures/sphinx
|
|
58
|
-
- spec/fixtures/sphinx/configuration.erb
|
|
59
|
-
- spec/fixtures/sphinx/people.old.spa
|
|
60
|
-
- spec/fixtures/sphinx/people.old.spd
|
|
61
|
-
- spec/fixtures/sphinx/people.old.sph
|
|
62
|
-
- spec/fixtures/sphinx/people.old.spi
|
|
63
|
-
- spec/fixtures/sphinx/people.old.spm
|
|
64
|
-
- spec/fixtures/sphinx/people.old.spp
|
|
65
|
-
- spec/fixtures/sphinx/people.spa
|
|
66
|
-
- spec/fixtures/sphinx/people.spd
|
|
67
|
-
- spec/fixtures/sphinx/people.sph
|
|
68
|
-
- spec/fixtures/sphinx/people.spi
|
|
69
|
-
- spec/fixtures/sphinx/people.spm
|
|
70
|
-
- spec/fixtures/sphinx/people.spp
|
|
71
|
-
- spec/fixtures/sphinx/searchd.log
|
|
72
|
-
- spec/fixtures/sphinx/searchd.query.log
|
|
73
|
-
- spec/fixtures/sphinx/spec.conf
|
|
74
|
-
- spec/fixtures/sphinxapi.php
|
|
75
|
-
- spec/fixtures/sql
|
|
76
|
-
- spec/fixtures/sql/conf.example.yml
|
|
77
|
-
- spec/fixtures/sql/conf.yml
|
|
78
|
-
- spec/fixtures/sql/data.sql
|
|
79
|
-
- spec/fixtures/sql/structure.sql
|
|
80
|
-
- spec/functional
|
|
81
|
-
- spec/functional/excerpt_spec.rb
|
|
82
|
-
- spec/functional/search_spec.rb
|
|
83
|
-
- spec/functional/update_spec.rb
|
|
84
|
-
- spec/spec_helper.rb
|
|
85
|
-
- spec/sphinx_helper.rb
|
|
86
|
-
- spec/unit
|
|
87
|
-
- spec/unit/client_spec.rb
|
|
88
|
-
- spec/unit/filter_spec.rb
|
|
89
|
-
- spec/unit/message_spec.rb
|
|
90
|
-
- spec/unit/response_spec.rb
|
|
91
32
|
has_rdoc: true
|
|
92
33
|
homepage: http://riddle.freelancing-gods.com
|
|
93
34
|
post_install_message:
|
|
@@ -120,6 +61,7 @@ specification_version: 2
|
|
|
120
61
|
summary: API for Sphinx, written in and for Ruby.
|
|
121
62
|
test_files:
|
|
122
63
|
- spec/functional/excerpt_spec.rb
|
|
64
|
+
- spec/functional/keywords_spec.rb
|
|
123
65
|
- spec/functional/search_spec.rb
|
|
124
66
|
- spec/functional/update_spec.rb
|
|
125
67
|
- spec/unit/client_spec.rb
|
|
Binary file
|
data/spec/fixtures/data/any.bin
DELETED
|
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
|
data/spec/fixtures/data/sort.bin
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
include 'sphinxapi.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
|
-
// update_simple
|
|
126
|
-
$file = fopen("spec/fixtures/data/update_simple.bin", "w");
|
|
127
|
-
fwrite($file, $client->UpdateAttributes("people", array("birthday"), array(1 => array(191163600))));
|
|
128
|
-
fclose($file);
|
|
129
|
-
|
|
130
|
-
?>
|