qiita-elasticsearch 0.14.1 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/qiita/elasticsearch/matchable_token.rb +24 -12
- data/lib/qiita/elasticsearch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5f80e83a36a13265613558a8c0ac97e8723850
|
4
|
+
data.tar.gz: a2ec7213540de6dda2a2e5004cffa09bd5eccc68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9aa9b37c7bf0b96f95fdff0d985c4020cf15c510e4c0036496de00e40ad71c8d889c59d33f9605a3139a897a0dbc6a0d549612effac1cb2682212a285849b2
|
7
|
+
data.tar.gz: 4e95b016526f3144eb336fe04f8d4fc275aeecd992338ad863f4a6c677e4fbebef7b65c31b4d15eabab7eba59a822fb7f0181837b78c113e8f840737498c52df
|
data/CHANGELOG.md
CHANGED
@@ -3,27 +3,39 @@ require "qiita/elasticsearch/token"
|
|
3
3
|
module Qiita
|
4
4
|
module Elasticsearch
|
5
5
|
class MatchableToken < Token
|
6
|
+
RELATIVE_BEST_FIELDS_QUERY_WEIGHT = 0.5
|
7
|
+
|
6
8
|
attr_writer :matchable_fields
|
7
9
|
|
8
10
|
# @return [Hash]
|
9
11
|
def to_hash
|
10
|
-
if
|
11
|
-
|
12
|
-
quoted? ? "match_phrase" : "match" => {
|
13
|
-
"_all" => @term,
|
14
|
-
}
|
15
|
-
}
|
12
|
+
if quoted?
|
13
|
+
build_multi_match_query(type: "phrase")
|
16
14
|
else
|
17
|
-
|
18
|
-
"
|
19
|
-
"
|
20
|
-
|
15
|
+
{
|
16
|
+
"bool" => {
|
17
|
+
"should" => [
|
18
|
+
build_multi_match_query(type: "phrase"),
|
19
|
+
build_multi_match_query(type: "best_fields", boost: RELATIVE_BEST_FIELDS_QUERY_WEIGHT),
|
20
|
+
],
|
21
21
|
},
|
22
22
|
}
|
23
|
-
hash["multi_match"]["type"] = "phrase" if quoted?
|
24
|
-
hash
|
25
23
|
end
|
26
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# @return [Hash]
|
29
|
+
def build_multi_match_query(type: nil, boost: 1)
|
30
|
+
{
|
31
|
+
"multi_match" => {
|
32
|
+
"boost" => boost,
|
33
|
+
"fields" => @matchable_fields || ["_all"],
|
34
|
+
"query" => @term,
|
35
|
+
"type" => type,
|
36
|
+
},
|
37
|
+
}
|
38
|
+
end
|
27
39
|
end
|
28
40
|
end
|
29
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.2.2
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Elasticsearch client helper for Qiita.
|