From 798397df55f848c77ea136608e2bc3008125aa97 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 14 Jul 2019 23:14:15 -0400 Subject: [PATCH] Added _script operator (commented out) [skip ci] --- lib/searchkick/query.rb | 2 ++ test/where_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index fe5a965..f7334bf 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -873,6 +873,8 @@ module Searchkick filters << {bool: {must_not: where_filters(value)}} elsif field == :_and filters << {bool: {must: value.map { |or_statement| {bool: {filter: where_filters(or_statement)}} }}} + # elsif field == :_script + # filters << {script: {script: {source: value, lang: "painless"}}} else # expand ranges if value.is_a?(Range) diff --git a/test/where_test.rb b/test/where_test.rb index 317cfb8..8a7e2d5 100644 --- a/test/where_test.rb +++ b/test/where_test.rb @@ -128,6 +128,14 @@ class WhereTest < Minitest::Test assert_search "product", ["Product A"], where: {user_ids: {exists: true}} end + # def test_script + # store [ + # {name: "Product A", store_id: 1}, + # {name: "Product B", store_id: 10} + # ] + # assert_search "product", ["Product A"], where: {_script: "doc['store_id'].value < 10"} + # end + def test_where_string store [ {name: "Product A", color: "RED"} -- libgit2 0.21.0