elasticrepo 0.0.4 → 0.0.5

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: b27a7c15f78466f02c2b2b117beaf7ed865d69f8
4
- data.tar.gz: d1d654a66b39aaa4e12084bbb923b095b4856e3c
3
+ metadata.gz: b4b102d6c68db954c7ef09e8e21746274b9b5bb0
4
+ data.tar.gz: ded8086823d99790ef30f7c50c669801f888b108
5
5
  SHA512:
6
- metadata.gz: c5a00b7158acd0c3f3cd3450747e52a4272738f1a0c9283d8f04f85a7f72d7d679dbbbcfa7f4ca1bec55fca464fe78bdcafee16bc2f7f8bebf7c57efc0d5eb89
7
- data.tar.gz: ae49d66407189500ade52c7d9b8458aef0649c8f4f830ba46e1d57270f4a7a557e0e3c1adae068cb40bfd693b7bc89d8e732af343685f2b99a92867e7ec65dcb
6
+ metadata.gz: a5e8ad2c43f614e579e5e338ab87a0496a270834b0b6d85e1d02b648f944c0ee966c8dde448ea354b373bb854c07a83c759d09a607563d6f84256e85b4a44809
7
+ data.tar.gz: c176388f178049e12bd9370f8c402e067ed6635d24ee4c86a601456e2a31d78eb20318dcac5d03b76f6e37ba2c8522e89e4cc129937f370fcd6206536d51d16e
@@ -1,6 +1,5 @@
1
1
  module Elasticrepo
2
2
  class Indexer
3
- #attr_reader :indexed
4
3
 
5
4
  def initialize(owner)
6
5
  @owner = owner
@@ -12,56 +11,55 @@ module Elasticrepo
12
11
  # GET /users/:user/starred
13
12
  #
14
13
  repos = Elasticrepo::Extractor.new(@owner).repos
15
-
16
14
  # index the extraction
17
15
  #
18
- @index = Tire::Index.new(@idx) do
19
- # Create the index with proper mapping (if doesn not exist already
16
+ Tire::Index.new(@idx) do
17
+ # Import documents
18
+ #
19
+ import repos
20
+ # Refresh the index for immediate searching
21
+ #
22
+ refresh
23
+ end
24
+ end
25
+
26
+ def import_with_map
27
+ repos = Elasticrepo::Extractor.new(@owner).repos
28
+ Tire::Index.new(@idx) do
29
+ # Create the index with proper mapping (if doesn not exist already)
20
30
  #
21
31
  create :mappings => {
22
32
  :question => {
23
33
  :properties => {
24
34
  :id => { :type => 'integer', :analyzer => 'keyword' },
25
- :owner => { :type => 'string', :analyzer => 'keyword' },
26
- :name => { :type => 'string', :analyzer => 'keyword' },
27
- #:full_name => { :type => 'string', :analyzer => 'keyword' },
28
- :url => { :type => 'string', :analyzer => 'snowball' },
29
- :description => { :type => 'string', :analyzer => 'snowball' },
30
- :organization => { :type => 'string', :analyzer => 'keyword' },
31
- :language => { :type => 'string', :analyzer => 'keyword' },
32
- :created_at => { :type => 'date', :analyzer => 'keyword' },
33
- :pushed_at => { :type => 'date', :analyzer => 'keyword' },
34
- :updated_at => { :type => 'date', :analyzer => 'keyword' }
35
+ :owner => { :type => 'string', :analyzer => 'keyword' },
36
+ :name => { :type => 'string', :analyzer => 'keyword' },
37
+ #:full_name => { :type => 'string', :analyzer => 'keyword' },
38
+ :url => { :type => 'string', :analyzer => 'snowball' },
39
+ :description => { :type => 'string', :analyzer => 'snowball' },
40
+ :organization => { :type => 'string', :analyzer => 'keyword' },
41
+ :language => { :type => 'string', :analyzer => 'keyword' },
42
+ :created_at => { :type => 'date', :analyzer => 'keyword' },
43
+ :pushed_at => { :type => 'date', :analyzer => 'keyword' },
44
+ :updated_at => { :type => 'date', :analyzer => 'keyword' }
35
45
  }
36
46
  }
37
47
  }
38
- # Import documents
39
- #
40
48
  import repos
41
- # Refresh the index for immediate searching
42
- #
43
49
  refresh
44
50
  end
45
51
  end # end import
46
52
 
47
- def search(sub_string)
48
- # search for a sub_string
49
- #
50
- search = Tire::Search::Search.new(@idx)
51
- search.query { string('description:"#{sub_string}"') }
52
- search.results
53
- end
54
-
55
53
  def update
56
54
  # Just refresh the index as is
57
55
  #
58
- @index.refresh
56
+ Tire::Index.new(@idx).refresh
59
57
  end
60
58
 
61
59
  def delete
62
60
  # delete 'repositories' index
63
61
  #
64
- @index.delete
62
+ Tire::Index.new(@idx).delete
65
63
  end
66
64
  end # end class
67
65
  end # end module
@@ -1,3 +1,3 @@
1
1
  module Elasticrepo
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticrepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca G. Soave
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-27 00:00:00.000000000 Z
11
+ date: 2013-04-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Feed me.