friendlyfashion-thinking-sphinx 2.0.13.3 → 2.0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWFjNTMyOTc0ZTJjYWEwNzVlNGVjMGM4YjA4MDhhNzAyNjU0ZTcyMA==
5
+ data.tar.gz: !binary |-
6
+ NmYyODgwOGU4NTIzYWUxY2U3ZjQ4M2Y0Mzc1NWIwNjA3M2QwYTA5Yw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZTRiNzcxNWI2Y2MyZGZlZmZlZjQ0NWZiYzUzZDQ5ZWM0OWQ4NTYzNzExZTBk
10
+ YzExNjM2Mjk2NWFlNDliNGQ0ZTk1YzY3Yzg0ZTc3NmRjZWE2ZTRiY2U3MzU2
11
+ MjFlNzQzNzk0NWJiM2Q3ZTU3NjY3ZTU0MWUxMWVmMGI2NTQzNmE=
12
+ data.tar.gz: !binary |-
13
+ MjViNjZjZjVmMmRhODNjMjU3Njc2YmExYWQ4ZjdlZjZlMDZkMTcwYmI1MWZm
14
+ NjA1MGU5YWZiMmExNzZhMzk5YjExMTg0ZDkzYjdjMDVlYTdiZTdjZDk5MWUx
15
+ NzMzZGJlMzg4MDZkZWQ2ZTg2N2MwN2EwOTc3ZWViMTk5MTg4YTM=
data/HISTORY CHANGED
@@ -1,9 +1,7 @@
1
- Edge:
1
+ 2.0.14 - January 2nd 2013
2
+ * Fix model loading for Rails 3.2.9 when subdirectories exist (Kenn Ejima).
2
3
  * Use BasicObject instead of BlankSlate when running on 1.9 (Steve Purcell).
3
- * Use full query in excerpts so double-stemming of terms is avoided (Jason Rust).
4
- * Fix thinking_sphinx:version rake task.
5
- * Directly compare non-string non-nil facet values for facet filters.
6
- * Don't bother checking with Sphinx whether documents exist when trying to update them. We're catching failures already (and Sphinx usually doesn't care anyway).
4
+ * 1.4.14 changes.
7
5
 
8
6
  2.0.13 - August 10th 2012
9
7
  * 1.4.13 changes.
@@ -71,6 +69,15 @@ Edge:
71
69
  * Rails 3 support.
72
70
  * 1.4.0 changes.
73
71
 
72
+ 1.4.14 - January 2nd 2013
73
+ * Allow sql_query_pre values to come through from config/sphinx.yml (George Ogata).
74
+ * ThinkingSphinx::Search#tap doesn't delegate through to the underlying array.
75
+ * Use fire_delta? instance method in the model (if it exists) to decide whether indexing should happen.
76
+ * Use full query in excerpts so double-stemming of terms is avoided (Jason Rust).
77
+ * Fix thinking_sphinx:version rake task.
78
+ * Directly compare non-string non-nil facet values for facet filters.
79
+ * Don't bother checking with Sphinx whether documents exist when trying to update them. We're catching failures already (and Sphinx usually doesn't care anyway).
80
+
74
81
  1.4.13 - August 10th 2012
75
82
  * Sphinx 2.0.5 support.
76
83
  * Hard retries for Sphinx exceptions (Andrew Hunter).
data/README.textile CHANGED
@@ -233,3 +233,4 @@ Since I first released this library, there's been quite a few people who have su
233
233
  * Nathan Smith
234
234
  * Cedric Maion
235
235
  * Steve Purcell
236
+ * George Ogata
@@ -2,13 +2,13 @@ Feature: Update attributes directly to Sphinx
2
2
  In order for updates to be more seamless
3
3
  The plugin
4
4
  Should update Sphinx's attributes where possible
5
-
5
+
6
6
  Scenario: Updating attributes in Sphinx without delta indexes
7
7
  Given Sphinx is running
8
8
  And I am searching on alphas
9
9
  When I filter by 3 on value
10
10
  Then I should get 1 result
11
-
11
+
12
12
  When I change the value of alpha four to 13
13
13
  And I wait for Sphinx to catch up
14
14
  And I filter by 13 on value
@@ -16,7 +16,7 @@ Feature: Update attributes directly to Sphinx
16
16
  Then I should get 1 result
17
17
  When I use index alternative_core
18
18
  Then I should get 1 result
19
-
19
+
20
20
  When I change the value of alpha four to 4
21
21
  And I wait for Sphinx to catch up
22
22
  And I filter by 13 on value
@@ -30,47 +30,49 @@ Feature: Update attributes directly to Sphinx
30
30
  And I am searching on betas
31
31
  When I filter by 8 on value
32
32
  Then I should get 1 result
33
-
33
+
34
34
  When I change the value of beta eight to 18
35
35
  And I wait for Sphinx to catch up
36
36
  And I filter by 18 on value
37
37
  Then I should get 1 result
38
-
38
+
39
39
  When I search for the document id of beta eight in the secondary_beta_delta index
40
40
  Then it should not exist
41
-
41
+
42
42
  Scenario: Updating attributes in a delta index
43
43
  Given Sphinx is running
44
44
  And I am searching on betas
45
-
45
+
46
46
  When I change the name of beta nine to nineteen
47
47
  And I change the value of beta nineteen to 19
48
48
  And I wait for Sphinx to catch up
49
-
49
+
50
50
  When I filter by 19 on value
51
51
  And I use index secondary_beta_delta
52
+ And I clear the connection pool
52
53
  Then I should get 1 result
53
-
54
+
54
55
  Scenario: Updating attributes in a delta index with deltas disabled
55
56
  Given Sphinx is running
56
57
  And I am searching on betas
57
-
58
+
58
59
  When I change the name of beta eleven to twentyone
59
60
  And I disable delta updates
60
61
  And I change the value of beta twentyone to 21
61
62
  And I wait for Sphinx to catch up
62
-
63
+ And I clear the connection pool
64
+
63
65
  When I filter by 21 on value
64
66
  And I use index secondary_beta_delta
65
67
  Then I should get 1 result
66
68
  And I enable delta updates
67
-
69
+
68
70
  Scenario: Updating boolean attribute in Sphinx
69
71
  Given Sphinx is running
70
72
  And I am searching on alphas
71
73
  When I filter by active alphas
72
74
  Then I should get 10 results
73
-
75
+
74
76
  When I flag alpha five as inactive
75
77
  And I wait for Sphinx to catch up
76
78
  And I filter by active alphas
@@ -2,50 +2,52 @@ Feature: Keeping Sphinx in line with deleted model instances
2
2
  In order to avoid deleted items being returned by Sphinx
3
3
  Thinking Sphinx
4
4
  Should keep deleted items out of search results
5
-
5
+
6
6
  Scenario: Deleting instances from the core index
7
7
  Given Sphinx is running
8
8
  And I am searching on betas
9
9
  When I search for three
10
10
  Then I should get 1 result
11
-
11
+
12
12
  When I destroy beta three
13
13
  And I wait for Sphinx to catch up
14
14
  And I search for three
15
15
  Then I should get 0 results
16
-
16
+
17
17
  Scenario: Deleting subclasses when the parent class is indexed
18
18
  Given Sphinx is running
19
19
  And I am searching on cats
20
20
  When I search for moggy
21
21
  Then I should get 1 result
22
-
22
+
23
23
  When I destroy cat moggy
24
24
  And I wait for Sphinx to catch up
25
25
  And I search for moggy
26
26
  Then I should get 0 results
27
-
27
+
28
28
  Scenario: Deleting created instances from the delta index
29
29
  Given Sphinx is running
30
30
  And I am searching on betas
31
31
  When I create a new beta named eleven
32
32
  And I wait for Sphinx to catch up
33
+ And I clear the connection pool
33
34
  And I search for eleven
34
35
  Then I should get 1 result
35
-
36
+
36
37
  When I destroy beta eleven
37
38
  And I wait for Sphinx to catch up
38
39
  And I search for eleven
39
40
  Then I should get 0 results
40
-
41
+
41
42
  Scenario: Deleting edited instances from the delta index
42
43
  Given Sphinx is running
43
44
  And I am searching on betas
44
45
  When I change the name of beta four to fourteen
45
46
  And I wait for Sphinx to catch up
47
+ And I clear the connection pool
46
48
  And I search for fourteen
47
49
  Then I should get 1 result
48
-
50
+
49
51
  When I destroy beta fourteen
50
52
  And I wait for Sphinx to catch up
51
53
  And I search for fourteen
@@ -56,9 +58,10 @@ Feature: Keeping Sphinx in line with deleted model instances
56
58
  And I am searching on betas
57
59
  When I create a new beta named thirteen
58
60
  And I wait for Sphinx to catch up
61
+ And I clear the connection pool
59
62
  And I search for thirteen
60
63
  Then I should get 1 result
61
-
64
+
62
65
  And I disable delta updates
63
66
  And I destroy beta thirteen
64
67
  And I wait for Sphinx to catch up
@@ -2,72 +2,75 @@ Feature: Keeping Sphinx in line with model changes when requested
2
2
  In order to keep indexes as up to date as possible
3
3
  Thinking Sphinx
4
4
  Should return the expected results depending on whether delta indexes are used
5
-
5
+
6
6
  Scenario: Returning instance from old data if there is no delta
7
7
  Given Sphinx is running
8
8
  And I am searching on alphas
9
9
  When I search for two
10
10
  Then I should get 1 result
11
-
11
+
12
12
  When I change the name of alpha two to twelve
13
13
  And I wait for Sphinx to catch up
14
14
  And I search for two
15
15
  Then I should get 1 result
16
-
16
+
17
17
  Scenario: Not returning an instance from old data if there is a delta
18
18
  Given Sphinx is running
19
19
  And I am searching on betas
20
20
  When I search for two
21
21
  Then I should get 1 result
22
-
22
+
23
23
  When I change the name of beta two to twelve
24
24
  And I wait for Sphinx to catch up
25
+ And I clear the connection pool
25
26
  And I search for two
26
27
  Then I should get 0 results
27
-
28
+
28
29
  Scenario: Returning instance from new data if there is a delta
29
30
  Given Sphinx is running
30
31
  And I am searching on betas
31
32
  When I search for one
32
33
  Then I should get 1 result
33
-
34
+
34
35
  When I change the name of beta one to eleventeen
35
36
  And I wait for Sphinx to catch up
37
+ And I clear the connection pool
36
38
  And I search for one
37
39
  Then I should get 0 results
38
-
40
+
39
41
  When I search for eleventeen
40
42
  Then I should get 1 result
41
-
43
+
42
44
  Scenario: Returning new records if there's a delta
43
45
  Given Sphinx is running
44
46
  And I am searching on betas
45
47
  When I search for fifteen
46
48
  Then I should get 0 results
47
-
49
+
48
50
  When I create a new beta named fifteen
49
51
  And I wait for Sphinx to catch up
52
+ And I clear the connection pool
50
53
  And I search for fifteen
51
54
  Then I should get 1 result
52
-
55
+
53
56
  Scenario: Avoiding delta updates if there hasn't been changes
54
57
  Given Sphinx is running
55
58
  And I am searching on betas
56
59
  When I search for five
57
60
  Then I should get 1 result
58
-
61
+
59
62
  When I change the name of beta five to five
60
63
  And I wait for Sphinx to catch up
61
64
  And I search for five
62
65
  Then I should get 1 result
63
-
66
+
64
67
  When I search for the document id of beta five in the beta_core index
65
68
  Then it should exist if using Rails 2.1 or newer
66
69
  When I search for the document id of beta five in the secondary_beta_core index
67
70
  Then it should exist if using Rails 2.1 or newer
68
71
  When I search for the document id of beta five in the secondary_beta_delta index
69
72
  Then it should not exist if using Rails 2.1 or newer
70
-
73
+
71
74
  Scenario: Handling edits with a delta when Sphinx isn't running
72
75
  Given Sphinx is running
73
76
  And I am searching on betas
@@ -76,19 +79,19 @@ Feature: Keeping Sphinx in line with model changes when requested
76
79
  And I start Sphinx
77
80
  And I search for sixteen
78
81
  Then I should get 1 result
79
-
82
+
80
83
  Scenario: Handling edits when updates are disabled
81
84
  Given Sphinx is running
82
85
  And updates are disabled
83
86
  And I am searching on betas
84
-
87
+
85
88
  When I search for seven
86
89
  Then I should get 1 result
87
-
90
+
88
91
  When I change the name of beta seven to seventeen
89
92
  And I wait for Sphinx to catch up
90
93
  And I search for seven
91
94
  Then I should get 1 result
92
-
95
+
93
96
  When I search for seventeen
94
97
  Then I should get 0 results
@@ -2,21 +2,21 @@ Feature: Searching within a single index
2
2
  In order to use Thinking Sphinx's core functionality
3
3
  A developer
4
4
  Should be able to search on a single index
5
-
5
+
6
6
  Scenario: Searching with alternative index
7
7
  Given Sphinx is running
8
8
  And I am searching on alphas
9
9
  When I order by value
10
10
  And I use index alternative_core
11
11
  Then I should get 7 results
12
-
12
+
13
13
  Scenario: Searching with default index
14
14
  Given Sphinx is running
15
15
  And I am searching on alphas
16
16
  When I order by value
17
17
  And I use index alpha_core
18
18
  Then I should get 10 results
19
-
19
+
20
20
  Scenario: Searching without specified index
21
21
  Given Sphinx is running
22
22
  And I am searching on alphas
@@ -26,14 +26,15 @@ Feature: Searching within a single index
26
26
  Scenario: Deleting instances from the core index
27
27
  Given Sphinx is running
28
28
  And I am searching on alphas
29
-
29
+
30
30
  When I create a new alpha named eleven
31
31
  And I process the alpha_core index
32
32
  And I process the alternative_core index
33
33
  And I wait for Sphinx to catch up
34
+ And I clear the connection pool
34
35
  And I search for eleven
35
36
  Then I should get 1 result
36
-
37
+
37
38
  When I destroy alpha eleven
38
39
  And I wait for Sphinx to catch up
39
40
  And I search for eleven
@@ -46,6 +46,10 @@ When /^I search for (\w+)$/ do |query|
46
46
  @query = query
47
47
  end
48
48
 
49
+ When /^I clear the connection pool$/ do
50
+ ThinkingSphinx::Connection.pool.clear
51
+ end
52
+
49
53
  When /^I search for "([^\"]*)"$/ do |query|
50
54
  @results = nil
51
55
  @query = query
@@ -40,10 +40,11 @@ module ThinkingSphinx
40
40
  end
41
41
 
42
42
  def update_index(index_name, attribute_names, attribute_values)
43
- config = ThinkingSphinx::Configuration.instance
44
- config.client.update index_name, attribute_names, {
45
- sphinx_document_id => attribute_values
46
- }
43
+ ThinkingSphinx::Connection.take do |client|
44
+ client.update index_name, attribute_names, {
45
+ sphinx_document_id => attribute_values
46
+ }
47
+ end
47
48
  rescue Riddle::ConnectionError, Riddle::ResponseError,
48
49
  ThinkingSphinx::SphinxError, Errno::ETIMEDOUT
49
50
  # Not the end of the world if Sphinx isn't running.
@@ -270,9 +270,9 @@ module ThinkingSphinx
270
270
  def delete_in_index(index, document_id)
271
271
  return unless ThinkingSphinx.sphinx_running?
272
272
 
273
- ThinkingSphinx::Configuration.instance.client.update(
274
- index, ['sphinx_deleted'], {document_id => [1]}
275
- )
273
+ ThinkingSphinx::Connection.take do |client|
274
+ client.update index, ['sphinx_deleted'], {document_id => [1]}
275
+ end
276
276
  rescue Riddle::ConnectionError, Riddle::ResponseError,
277
277
  ThinkingSphinx::SphinxError, Errno::ETIMEDOUT, Timeout::Error
278
278
  # Not the end of the world if Sphinx isn't running.
@@ -51,6 +51,13 @@ module ThinkingSphinx
51
51
  :mysql
52
52
  when "jdbcpostgresql"
53
53
  :postgresql
54
+ when "jdbc"
55
+ match = /^jdbc:(mysql|postgresql):\/\//.match(model.connection.config[:url])
56
+ if match
57
+ match[1].to_sym
58
+ else
59
+ model.connection.config[:adapter]
60
+ end
54
61
  else
55
62
  model.connection.config[:adapter].to_sym
56
63
  end
@@ -1,19 +1,15 @@
1
1
  module ThinkingSphinx
2
2
  class BundledSearch
3
- attr_reader :client
4
-
5
3
  def initialize
6
4
  @searches = []
7
5
  end
8
6
 
9
7
  def search(*args)
10
8
  @searches << ThinkingSphinx.search(*args)
11
- @searches.last.append_to client
12
9
  end
13
10
 
14
11
  def search_for_ids(*args)
15
12
  @searches << ThinkingSphinx.search_for_ids(*args)
16
- @searches.last.append_to client
17
13
  end
18
14
 
19
15
  def searches
@@ -23,10 +19,6 @@ module ThinkingSphinx
23
19
 
24
20
  private
25
21
 
26
- def client
27
- @client ||= ThinkingSphinx::Configuration.instance.client
28
- end
29
-
30
22
  def populated?
31
23
  @populated
32
24
  end
@@ -36,8 +28,12 @@ module ThinkingSphinx
36
28
 
37
29
  @populated = true
38
30
 
39
- client.run.each_with_index do |results, index|
40
- searches[index].populate_from_queue results
31
+ ThinkingSphinx::Connection.take do |client|
32
+ @searches.each { |search| search.append_to client }
33
+
34
+ client.run.each_with_index do |results, index|
35
+ searches[index].populate_from_queue results
36
+ end
41
37
  end
42
38
  end
43
39
  end