elastic_record 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/elastic_record.gemspec +1 -1
- data/lib/elastic_record/lucene.rb +5 -1
- data/test/elastic_record/lucene_test.rb +1 -0
- metadata +2 -2
data/elastic_record.gemspec
CHANGED
@@ -11,11 +11,15 @@ module ElasticRecord
|
|
11
11
|
query.gsub(ESCAPE_REGEX, "\\\\\\1")
|
12
12
|
end
|
13
13
|
|
14
|
+
def query_words(query)
|
15
|
+
Shellwords::shellwords query.gsub("'", "\"'\"")
|
16
|
+
end
|
17
|
+
|
14
18
|
# Returns a lucene query that works like G
|
15
19
|
def smart_query(query, fields, &block)
|
16
20
|
return if query.blank?
|
17
21
|
|
18
|
-
words =
|
22
|
+
words = query_words(query)
|
19
23
|
|
20
24
|
words.map do |word|
|
21
25
|
if word =~ /^(\w+):(.+)$/ && fields.include?($1)
|
@@ -11,6 +11,7 @@ class ElasticRecord::LuceneTest < MiniTest::Spec
|
|
11
11
|
assert_smart_escape nil, nil, ['name']
|
12
12
|
|
13
13
|
assert_smart_escape '(name:foo*)', 'foo', ['name']
|
14
|
+
assert_smart_escape "(name:bob's*)", "bob's", ['name']
|
14
15
|
assert_smart_escape '(name.analyzed:foo*)', 'foo', ['name'] { |f| "#{f}.analyzed" }
|
15
16
|
assert_smart_escape '(name:foo* OR street:foo*)', 'foo', ['name', 'street']
|
16
17
|
assert_smart_escape '(name:"foo bar" OR street:"foo bar") AND (name:faz* OR street:faz*)', '"foo bar" faz', ['name', 'street']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arelastic
|