You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/01/09 08:25:18 UTC

[GitHub] willholley closed pull request #1098: Mango: fallback to "selector" on empty "partial_filter_selector"

willholley closed pull request #1098: Mango: fallback to "selector" on empty "partial_filter_selector"
URL: https://github.com/apache/couchdb/pull/1098
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/mango/src/mango_native_proc.erl b/src/mango/src/mango_native_proc.erl
index 7a34201939..6150e1d19b 100644
--- a/src/mango/src/mango_native_proc.erl
+++ b/src/mango/src/mango_native_proc.erl
@@ -172,19 +172,12 @@ get_text_entries({IdxProps}, Doc) ->
 
 
 get_index_partial_filter_selector(IdxProps) ->
-    case couch_util:get_value(<<"partial_filter_selector">>, IdxProps) of
-        undefined ->
+    case couch_util:get_value(<<"partial_filter_selector">>, IdxProps, {[]}) of
+        {[]} ->
             % this is to support legacy text indexes that had the partial_filter_selector
             % set as selector
-            case couch_util:get_value(<<"selector">>, IdxProps, []) of
-                [] -> 
-                    {[]};
-                Else -> 
-                    Else
-            end;
-        [] -> 
-            {[]};
-        Else -> 
+            couch_util:get_value(<<"selector">>, IdxProps, {[]});
+        Else ->
             Else
     end.
 
diff --git a/src/mango/test/16-index-selectors-test.py b/src/mango/test/16-index-selectors-test.py
index 389f5f41e3..a876dc68f0 100644
--- a/src/mango/test/16-index-selectors-test.py
+++ b/src/mango/test/16-index-selectors-test.py
@@ -271,6 +271,16 @@ def test_text_old_selector_still_supported(self):
         docs = self.db.find(selector, use_index='oldschooltext')
         self.assertEqual(len(docs), 3)
 
+    @unittest.skipUnless(mango.has_text_service(), "requires text service")
+    def test_text_old_selector_still_supported_via_api(self):
+        selector = {"location": {"$gte": "FRA"}}
+        self.db.create_text_index(fields=[{"name":"location", "type":"string"}], 
+            selector=selector, 
+            ddoc="Selected", 
+            name="Selected")
+        docs = self.db.find({"location": {"$exists":True}}, use_index='Selected')
+        self.assertEqual(len(docs), 3)
+
     @unittest.skipUnless(mango.has_text_service(), "requires text service")
     def test_text_partial_filter_only_in_return_if_not_default(self):
         self.db.create_text_index(fields=[{"name":"location", "type":"string"}])
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index ecf969e04e..9b6b998cd6 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -145,7 +145,7 @@ def create_index(self, fields, idx_type="json", name=None, ddoc=None,
         return created
 
     def create_text_index(self, analyzer=None, idx_type="text",
-        partial_filter_selector=None, default_field=None, fields=None, 
+        partial_filter_selector=None, selector=None, default_field=None, fields=None, 
         name=None, ddoc=None,index_array_lengths=None):
         body = {
             "index": {
@@ -161,6 +161,8 @@ def create_text_index(self, analyzer=None, idx_type="text",
             body["index"]["default_field"] = default_field
         if index_array_lengths is not None:
             body["index"]["index_array_lengths"] = index_array_lengths
+        if selector is not None:
+            body["index"]["selector"] = selector
         if partial_filter_selector is not None:
             body["index"]["partial_filter_selector"] = partial_filter_selector
         if fields is not None:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services