elasticrepo 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/lib/elasticrepo/indexer.rb +26 -28
- data/lib/elasticrepo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4b102d6c68db954c7ef09e8e21746274b9b5bb0
|
4
|
+
data.tar.gz: ded8086823d99790ef30f7c50c669801f888b108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5e8ad2c43f614e579e5e338ab87a0496a270834b0b6d85e1d02b648f944c0ee966c8dde448ea354b373bb854c07a83c759d09a607563d6f84256e85b4a44809
|
7
|
+
data.tar.gz: c176388f178049e12bd9370f8c402e067ed6635d24ee4c86a601456e2a31d78eb20318dcac5d03b76f6e37ba2c8522e89e4cc129937f370fcd6206536d51d16e
|
data/lib/elasticrepo/indexer.rb
CHANGED
@@ -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
|
-
|
19
|
-
#
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
@
|
56
|
+
Tire::Index.new(@idx).refresh
|
59
57
|
end
|
60
58
|
|
61
59
|
def delete
|
62
60
|
# delete 'repositories' index
|
63
61
|
#
|
64
|
-
@
|
62
|
+
Tire::Index.new(@idx).delete
|
65
63
|
end
|
66
64
|
end # end class
|
67
65
|
end # end module
|
data/lib/elasticrepo/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Feed me.
|