elastic_record 0.9.0 → 0.9.1

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '0.9.0'
5
+ s.version = '0.9.1'
6
6
  s.summary = 'Use Elastic Search with your objects'
7
7
  s.description = 'Find your records with elastic search'
8
8
 
@@ -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 = Shellwords::shellwords(query)
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.0
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-18 00:00:00.000000000 Z
12
+ date: 2012-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic