Commit 798397df55f848c77ea136608e2bc3008125aa97

Authored by Andrew Kane
1 parent 8ab42500

Added _script operator (commented out) [skip ci]

Showing 2 changed files with 10 additions and 0 deletions   Show diff stats
lib/searchkick/query.rb
@@ -873,6 +873,8 @@ module Searchkick @@ -873,6 +873,8 @@ module Searchkick
873 filters << {bool: {must_not: where_filters(value)}} 873 filters << {bool: {must_not: where_filters(value)}}
874 elsif field == :_and 874 elsif field == :_and
875 filters << {bool: {must: value.map { |or_statement| {bool: {filter: where_filters(or_statement)}} }}} 875 filters << {bool: {must: value.map { |or_statement| {bool: {filter: where_filters(or_statement)}} }}}
  876 + # elsif field == :_script
  877 + # filters << {script: {script: {source: value, lang: "painless"}}}
876 else 878 else
877 # expand ranges 879 # expand ranges
878 if value.is_a?(Range) 880 if value.is_a?(Range)
test/where_test.rb
@@ -128,6 +128,14 @@ class WhereTest &lt; Minitest::Test @@ -128,6 +128,14 @@ class WhereTest &lt; Minitest::Test
128 assert_search "product", ["Product A"], where: {user_ids: {exists: true}} 128 assert_search "product", ["Product A"], where: {user_ids: {exists: true}}
129 end 129 end
130 130
  131 + # def test_script
  132 + # store [
  133 + # {name: "Product A", store_id: 1},
  134 + # {name: "Product B", store_id: 10}
  135 + # ]
  136 + # assert_search "product", ["Product A"], where: {_script: "doc['store_id'].value < 10"}
  137 + # end
  138 +
131 def test_where_string 139 def test_where_string
132 store [ 140 store [
133 {name: "Product A", color: "RED"} 141 {name: "Product A", color: "RED"}