s3search 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2f409bf1d5943a4bba14de2d68380fd42de29e5
4
- data.tar.gz: fa9aae7844c80c61be5fca34bfbf1d18be16b3f3
3
+ metadata.gz: 93860ffead9f069dc475c369b5cf87942f1e22c6
4
+ data.tar.gz: 020a5ed8bd7c10c4d8d6937d4a3d6b8523bdf742
5
5
  SHA512:
6
- metadata.gz: 17497e746c81e2e54ab2690b64e4a27f8b98cca4f24a79772bbe81044cb70acec9d0c1ad95dc2c5b6e80e9e28917f46d61c0a236bd81588120dd544e5ce75672
7
- data.tar.gz: 0d79ac7927201e5a74a407d865c83622b0e072f2ca3f966c0c79a4c24a04f163b6afaba16ab211d636401666e575c97166ec1f9ee940b8d0de3ee0606625f764
6
+ metadata.gz: 2b3c57cd0b7ad978ad99a93c05cab3bf1863edc52b30c75c0b70ae0f0b38770f892c1dcb8407464da709e375ba83e4b53ce64bd734bfc3e4482652cb0143bfd6
7
+ data.tar.gz: c3c1ba2c23cb56c446bc790c67d4811291f196809d0e15d247bc303830f1a46cf372bdd38ede0ef2b05a547412823fe3229826196f2a81ab17ad54879b99cf2b
data/HEROKU.md ADDED
@@ -0,0 +1,141 @@
1
+ [S3Search](http://addons.heroku.com/s3search) is an [add-on](http://addons.heroku.com) for providing powerful document-based full-text indexing and search to your application.
2
+
3
+ Adding S3Search to your application will allow you search your documents based upon the actual text within the documents, as well as any metadata fields you assign to them. Yes, that's right! S3Search will index the text inside your documents.
4
+
5
+ Do you already have documents stored and want to index them and make them searchable? No worries. S3Search works by you sending it a URL to fetch the document content to index, along with a hash of metadata attributes to record against it. You can them perform powerful queries against that indexed data, based on the rich features of [elasticsearch](http://www.elasticsearch.org).
6
+
7
+ S3Search is accessible via an API, or HTTP, and currently has a supported client library for Ruby.
8
+
9
+ ## Provisioning the add-on
10
+
11
+ S3Search can be attached to a Heroku application via the CLI:
12
+
13
+ <div class="callout" markdown="1">
14
+ A list of all plans available can be found [here](http://addons.heroku.com/s3search).
15
+ </div>
16
+
17
+ :::term
18
+ $ heroku addons:add s3search
19
+ -----> Adding s3search to sharp-mountain-4005... done, v18 (free)
20
+
21
+ Once S3Search has been added a `S3SEARCH_URL` setting will be available in the app configuration and will contain your custom URL to access the newly provisioned S3Search service instance. This can be confirmed using the `heroku config:get` command.
22
+
23
+ :::term
24
+ $ heroku config:get S3SEARCH_URL
25
+ https://user:pass@us-east-1.s3searchapp.com
26
+
27
+ After installing S3Search the application should be configured to fully integrate with the add-on.
28
+
29
+ ## Using with Rails 3.x
30
+
31
+ Ruby on Rails applications will need to add the following entry into their `Gemfile` specifying the S3Search client library.
32
+
33
+ :::ruby
34
+ gem 's3search'
35
+
36
+ Update application dependencies with bundler.
37
+
38
+ :::term
39
+ $ bundle install
40
+
41
+ Write some application code to index some documents.
42
+
43
+ :::ruby
44
+ S3Search::Document.create title: 'MyDocument', _content_url: 'https://s3-us-east-1.amazonaws.com/my_bucket/my_document.pdf'
45
+ S3Search::Document.create name: 'Bob Lob Law', resume_id: 25, _content_url: 'https://s3-us-east-1.amazonaws.com/resumes.mycompany.com/bob.pdf'
46
+
47
+ The documents don't even really need to be in S3.
48
+
49
+ :::ruby
50
+ S3Search::Document.create name: 'Bitcoin Pirate', resume_id: 42, _content_url: 'https://user:pass@authenticatedlocation.com/docs/jenny.pdf'
51
+ S3Search::Document.create title: 'Bitcoin', author: 'santoshin@gmx.com', tags: ['bitcoin', 'manifesto'], _content_url: 'http://bitcoin.org/bitcoin.pdf'
52
+
53
+ The documents don't even really need to be documents! You can use S3Search to use its powerful search capability over just your custom metadata.
54
+
55
+ :::ruby
56
+ S3Search::Document.create customer_id: 32, first_name: 'His Holiness', last_name: 'The Dalia Lama', religion: 'Buddhist', twitter_handle: '@DalaiLama'
57
+ S3Search::Document.create customer_id: 99, first_name: 'George', middle_name: 'R. R.', last_name: 'Martin', job_title: 'Author'
58
+
59
+ Now retrieve some documents via the powerful query API.
60
+
61
+ Search by a single metadata field
62
+
63
+ :::ruby
64
+ results = S3Search::Document.search(title: 'MyDocument')
65
+
66
+ Search all metadata fields AND the content of the documents.
67
+
68
+ :::ruby
69
+ results = S3Search::Document.search('bitcoin')
70
+
71
+ Search only the content of the documents.
72
+
73
+ :::ruby
74
+ results = S3Search::Document.search(_document_content: 'bitcoin')
75
+
76
+ Boost the search ranking of a certain field.
77
+
78
+ :::ruby
79
+ results = S3Search::Document.search('bitcoin', boost: { title: 2.5 })
80
+
81
+ Find a single document based on its unique id.
82
+
83
+ :::ruby
84
+ document = S3Search::Document.get '833FCA4EEEF2943AC2D8E0'
85
+
86
+ ## Monitoring & Logging
87
+
88
+ Stats and the current state of S3Search can be displayed via the CLI.
89
+
90
+ :::term
91
+ $ heroku s3search:status
92
+ documents_indexed: 32842
93
+ index_size: 640MB
94
+
95
+ S3Search activity can be observed within the Heroku log-stream.
96
+
97
+ :::term
98
+ $ heroku logs -t | grep 's3search'
99
+
100
+ ## Dashboard
101
+
102
+ <div class="callout" markdown="1">
103
+ For more information on the features available within the S3Search dashboard please see the docs at [heroku.s3searchapp.com/docs](heroku.s3searchapp.com/docs).
104
+ </div>
105
+
106
+ The S3Search dashboard allows you to view the current status of your S3Search cluster.
107
+
108
+ The dashboard can be accessed via the CLI:
109
+
110
+ :::term
111
+ $ heroku addons:open s3search
112
+ Opening s3search for sharp-mountain-4005…
113
+
114
+ or by visiting the [Heroku apps web interface](http://heroku.com/myapps) and selecting the application in question. Select S3Search from the Add-ons menu.
115
+
116
+ ## Migrating between plans
117
+
118
+ <div class="note" markdown="1">Application owners should carefully manage the migration timing to ensure proper application function during the migration process.</div>
119
+
120
+ Use the `heroku addons:upgrade` command to migrate to a new plan.
121
+
122
+ :::term
123
+ $ heroku addons:upgrade s3search:newplan
124
+ -----> Upgrading s3search:newplan to sharp-mountain-4005... done, v18 ($49/mo)
125
+ Your plan has been updated to: s3search:newplan
126
+
127
+ ## Removing the add-on
128
+
129
+ S3Search can be removed via the CLI.
130
+
131
+ <div class="warning" markdown="1">This will destroy all metadata and indexes stored in S3Search and cannot be undone! Of course, documents indexed in S3Search but stored elsewhere will remain untouched.</div>
132
+
133
+ :::term
134
+ $ heroku addons:remove s3search
135
+ -----> Removing s3search from sharp-mountain-4005... done, v20 (free)
136
+
137
+ Before removing S3Search a data export can be performed by contacting support@s3searchapp.com directly.
138
+
139
+ ## Support
140
+
141
+ All S3Search support and runtime issues should be submitted via on of the [Heroku Support channels](support-channels). Any non-support related issues or product feedback is welcome at feedback@s3searchapp.com.
data/README.md CHANGED
@@ -35,7 +35,7 @@ Once S3Search has been added a `S3SEARCH_URL` setting will be available in the a
35
35
 
36
36
  ```term
37
37
  $ heroku config:get S3SEARCH_URL
38
- https://user:pass@api.s3searchapp.com
38
+ https://user:pass@us-east-1.s3searchapp.com
39
39
  ```
40
40
 
41
41
  After installing S3Search the application should be configured to fully integrate with the add-on.
@@ -8,6 +8,8 @@ describe '/searches' do
8
8
  S3Search.delete doc.id
9
9
  end
10
10
 
11
+ baseline_query_count = S3Search.query_count
12
+
11
13
  title_a = SecureRandom.hex
12
14
  title_b = SecureRandom.hex
13
15
 
@@ -21,12 +23,15 @@ describe '/searches' do
21
23
 
22
24
  a_doc_ids = S3Search.create_many(a_docs).map(&:id)
23
25
  b_doc_ids = S3Search.create_many(b_docs).map(&:id)
26
+ expect(S3Search.query_count).to eq(baseline_query_count + 3)
27
+
24
28
  all_doc_ids = a_doc_ids + b_doc_ids
25
29
 
26
30
  S3Search.get_all(per_page: 20).each do |doc|
27
31
  expect(all_doc_ids).to include(doc.id)
28
32
  end
29
-
33
+ expect(S3Search.query_count).to eq(baseline_query_count + 5)
34
+
30
35
  results = S3Search.simple_search "title:#{title_a}", per_page: 4
31
36
  expect(results.size).to eq(4)
32
37
  results.each do |doc|
@@ -52,19 +57,12 @@ describe '/searches' do
52
57
  expect(b_doc_ids).to include(doc.id)
53
58
  end
54
59
 
55
- # begin
56
- # results.each do |result|
57
- # S3Search.delete result.id
58
- # end
59
- # end while results.next
60
-
61
- # document = S3Search.create title: 'blah'
62
- # expect(document.title).to eq('blah')
63
-
64
- # id = document.id
65
-
66
- # expect(S3Search.get(id).title).to eq('blah')
67
-
68
- # puts S3Search.search 'blah'
60
+ begin
61
+ results.each do |result|
62
+ S3Search.delete result.id
63
+ end
64
+ end while results.next
65
+
66
+ expect(S3Search.query_count).to eq(baseline_query_count + 20)
69
67
  end
70
68
  end
File without changes
@@ -0,0 +1,10 @@
1
+ module S3Search
2
+ module API
3
+ module Stats
4
+
5
+ def query_count
6
+ _get("/v1/stats/query_count.json").query_count
7
+ end
8
+ end
9
+ end
10
+ end
@@ -5,6 +5,7 @@ require 'hashie'
5
5
  require 'logger'
6
6
  require 's3search/api/documents'
7
7
  require 's3search/api/searches'
8
+ require 's3search/api/stats'
8
9
  require 's3search/request_error'
9
10
  require 's3search/version'
10
11
 
@@ -12,11 +13,12 @@ module S3Search
12
13
  class Client
13
14
  include S3Search::API::Documents
14
15
  include S3Search::API::Searches
16
+ include S3Search::API::Stats
15
17
 
16
18
  attr_reader :url, :http, :logger
17
19
 
18
20
  def initialize
19
- @url = ENV['S3SEARCH_URL'] || 'https://api.s3searchapp.com'
21
+ @url = ENV['S3SEARCH_URL'] || 'https://us-east-1.s3searchapp.com'
20
22
  @http = Faraday.new(:url => @url) do |builder|
21
23
  builder.response :mashify
22
24
  builder.response :json, :content_type => /\bjson$/
@@ -1,3 +1,3 @@
1
1
  module S3Search
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,7 +4,7 @@ describe 'getting all documents' do
4
4
  let(:document_jsons) { (1..27).map{ |i| Hashie::Mash.new(id: "id#{i}", _score: 1.0, name: "doc#{i}") } }
5
5
 
6
6
  def link page, per_page
7
- "https://api.s3searchapp.test/v1/documents.json?page=#{page}&per_page=#{per_page}"
7
+ "https://us-east-1.s3searchapp.test/v1/documents.json?page=#{page}&per_page=#{per_page}"
8
8
  end
9
9
 
10
10
  it 'takes per_page and page params' do
@@ -3,7 +3,7 @@ require 'active_support/core_ext/hash/deep_merge'
3
3
  describe 'search' do
4
4
 
5
5
  def link id, page, per_page
6
- "https://api.s3searchapp.test/v1/searches/abcde.json?page=#{page}&per_page=#{per_page}"
6
+ "https://us-east-1.s3searchapp.test/v1/searches/abcde.json?page=#{page}&per_page=#{per_page}"
7
7
  end
8
8
 
9
9
  let(:found_documents) { (1..70).map{|i| {id: SecureRandom.hex, name: "doc#{i}", _score: 1.0 / i}}}
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'active_support/core_ext/object/try'
4
4
 
5
5
  ENV['S3SEARCH_API_KEY'] = 'api_key'
6
6
  ENV['S3SEARCH_API_SECRET'] = 'api_secret'
7
- ENV['S3SEARCH_URL'] = 'https://@api.s3searchapp.test'
7
+ ENV['S3SEARCH_URL'] = 'https://us-east-1.s3searchapp.test'
8
8
 
9
9
  RSpec.configure do |config|
10
10
  config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -16,7 +16,7 @@ end
16
16
  def stub_api_http method, resource, body=nil, &block
17
17
  stub_request(
18
18
  method,
19
- "https://api.s3searchapp.test#{resource}"
19
+ "https://us-east-1.s3searchapp.test#{resource}"
20
20
  ).with(
21
21
  body: body.try(:to_json),
22
22
  headers: {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Aitchison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-17 00:00:00.000000000 Z
11
+ date: 2013-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -118,14 +118,17 @@ files:
118
118
  - .gitignore
119
119
  - .rspec
120
120
  - Gemfile
121
+ - HEROKU.md
121
122
  - LICENSE.txt
122
123
  - README.md
123
124
  - Rakefile
124
125
  - integration/document_spec.rb
125
126
  - integration/search_spec.rb
127
+ - integration/stats_spec.rb
126
128
  - lib/s3search.rb
127
129
  - lib/s3search/api/documents.rb
128
130
  - lib/s3search/api/searches.rb
131
+ - lib/s3search/api/stats.rb
129
132
  - lib/s3search/client.rb
130
133
  - lib/s3search/request_error.rb
131
134
  - lib/s3search/result_page.rb
@@ -167,6 +170,7 @@ summary: S3Search Ruby API
167
170
  test_files:
168
171
  - integration/document_spec.rb
169
172
  - integration/search_spec.rb
173
+ - integration/stats_spec.rb
170
174
  - spec/acceptance/document_create_many_spec.rb
171
175
  - spec/acceptance/document_create_spec.rb
172
176
  - spec/acceptance/document_delete_spec.rb