couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [4/5] couchdb-mango git commit: Return HTTP 501 index_not_implemented error for text indexes
Date Sat, 01 Aug 2015 15:50:50 GMT
Return HTTP 501 index_not_implemented error for text indexes

This feature requires FTS service implementation which is not available
yet.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/93a4bc10
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/93a4bc10
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/93a4bc10

Branch: refs/heads/master
Commit: 93a4bc10688a11dcdd027b616f863e34e87fd097
Parents: 6ba768f
Author: Alexander Shorin <kxepal@apache.org>
Authored: Wed Jul 29 22:31:32 2015 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Wed Jul 29 22:54:05 2015 +0300

----------------------------------------------------------------------
 src/mango_error.erl                    |  6 ++++++
 src/mango_idx.erl                      |  3 ++-
 test/04-key-tests.py                   |  5 ++++-
 test/05-index-selection-test.py        |  6 +++++-
 test/06-basic-text-test.py             | 25 +++++++++++++++++++++++++
 test/06-text-default-field-test.py     | 14 +++++++++++++-
 test/07-text-custom-field-list-test.py |  6 +++++-
 test/08-text-limit-test.py             |  5 +++++
 test/09-text-sort-test.py              |  6 +++++-
 9 files changed, 70 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/src/mango_error.erl
----------------------------------------------------------------------
diff --git a/src/mango_error.erl b/src/mango_error.erl
index dfd4bd7..69767cf 100644
--- a/src/mango_error.erl
+++ b/src/mango_error.erl
@@ -102,6 +102,12 @@ info(mango_idx, no_index_definition) ->
         <<"invalid_index">>,
         <<"Index is missing its definition.">>
     };
+info(mango_idx, {index_not_implemented, IndexName}) ->
+    {
+        501,
+        <<"index_not_implemented">>,
+        fmt("~s", [IndexName])
+    };
 
 info(mango_idx_view, {invalid_index_json, BadIdx}) ->
     {

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/src/mango_idx.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx.erl b/src/mango_idx.erl
index c886ab0..f6e688b 100644
--- a/src/mango_idx.erl
+++ b/src/mango_idx.erl
@@ -270,7 +270,8 @@ get_idx_def(Opts) ->
 get_idx_type(Opts) ->
     case proplists:get_value(type, Opts) of
         <<"json">> -> <<"json">>;
-        <<"text">> -> <<"text">>;
+        <<"text">> ->
+            ?MANGO_ERROR({index_not_implemented, <<"text">>});
         %<<"geo">> -> <<"geo">>;
         undefined -> <<"json">>;
         BadType ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/test/04-key-tests.py
----------------------------------------------------------------------
diff --git a/test/04-key-tests.py b/test/04-key-tests.py
index 0109737..ac0d3ec 100644
--- a/test/04-key-tests.py
+++ b/test/04-key-tests.py
@@ -13,7 +13,7 @@
 
 
 import mango
-
+import unittest
 
 TEST_DOCS = [
     {
@@ -56,6 +56,7 @@ TEST_DOCS = [
 class KeyTests(mango.DbPerClass):
     @classmethod
     def setUpClass(klass):
+        raise unittest.SkipTest('text index is not supported yet')
         super(KeyTests, klass).setUpClass()
         klass.db.save_docs(TEST_DOCS, w=3)
         klass.db.create_index(["type"], ddoc="view")
@@ -124,6 +125,7 @@ class KeyTests(mango.DbPerClass):
         for query in queries:
             self.run_check(query, check, indexes=["text"])
 
+    @unittest.skip
     def test_escape_period(self):
         query = {"name\\.first" : "Kvothe"}
         def check(docs):
@@ -136,6 +138,7 @@ class KeyTests(mango.DbPerClass):
             assert len(docs) == 0
         self.run_check(query, check_empty, indexes=["text"])
 
+    @unittest.skip
     def test_object_period(self):
         query = {"name.first" : "Master Elodin"}
         def check(docs):

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/test/05-index-selection-test.py
----------------------------------------------------------------------
diff --git a/test/05-index-selection-test.py b/test/05-index-selection-test.py
index 8c2c018..856e924 100644
--- a/test/05-index-selection-test.py
+++ b/test/05-index-selection-test.py
@@ -12,13 +12,14 @@
 
 import mango
 import user_docs
+import unittest
 
 
 class IndexSelectionTests(mango.UserDocsTests):
     @classmethod
     def setUpClass(klass):
         super(IndexSelectionTests, klass).setUpClass()
-        user_docs.add_text_indexes(klass.db, {})
+        # user_docs.add_text_indexes(klass.db, {})
 
     def test_basic(self):
         resp = self.db.find({"name.last": "A last name"}, explain=True)
@@ -31,10 +32,12 @@ class IndexSelectionTests(mango.UserDocsTests):
             }, explain=True)
         assert resp["index"]["type"] == "json"
 
+    @unittest.skip
     def test_no_view_index(self):
         resp = self.db.find({"name.first": "Ohai!"}, explain=True)
         assert resp["index"]["type"] == "text"
 
+    @unittest.skip
     def test_with_or(self):
         resp = self.db.find({
                 "$or": [
@@ -65,6 +68,7 @@ class IndexSelectionTests(mango.UserDocsTests):
 class MultiTextIndexSelectionTests(mango.UserDocsTests):
     @classmethod
     def setUpClass(klass):
+        raise unittest.SkipTest('text index is not supported yet')
         super(MultiTextIndexSelectionTests, klass).setUpClass()
         klass.db.create_text_index(ddoc="foo", analyzer="keyword")
         klass.db.create_text_index(ddoc="bar", analyzer="email")

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/test/06-basic-text-test.py
----------------------------------------------------------------------
diff --git a/test/06-basic-text-test.py b/test/06-basic-text-test.py
index 71eeb70..08739db 100644
--- a/test/06-basic-text-test.py
+++ b/test/06-basic-text-test.py
@@ -10,11 +10,31 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
+import json
 import mango
+import unittest
 import user_docs
 
 
+class TextIndexCheckTests(mango.DbPerClass):
+
+    def test_create_text_index(self):
+        body = json.dumps({
+            'index': {
+                'fields': 'test'
+            },
+            'type': 'text'
+        })
+        resp = self.db.sess.post(self.db.path("_index"), data=body)
+        assert resp.status_code == 501, resp
+
+
 class BasicTextTests(mango.UserDocsTextTests):
+
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text index is not supported yet')
+
     def test_simple(self):
         docs = self.db.find({"$text": "Stephanie"})
         assert len(docs) == 1
@@ -378,6 +398,11 @@ class BasicTextTests(mango.UserDocsTextTests):
 
 
 class ElemMatchTests(mango.FriendDocsTextTests):
+
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text index is not supported yet')
+
     def test_elem_match(self):
         q = {"friends": {
                 "$elemMatch":

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/test/06-text-default-field-test.py
----------------------------------------------------------------------
diff --git a/test/06-text-default-field-test.py b/test/06-text-default-field-test.py
index 691a885..b0fa911 100644
--- a/test/06-text-default-field-test.py
+++ b/test/06-text-default-field-test.py
@@ -11,13 +11,17 @@
 # the License.
 
 import mango
-
+import unittest
 
 
 class NoDefaultFieldTest(mango.UserDocsTextTests):
 
     DEFAULT_FIELD = False
 
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text not supported')
+
     def test_basic(self):
         docs = self.db.find({"$text": "Ramona"})
         # Or should this throw an error?
@@ -36,6 +40,10 @@ class NoDefaultFieldWithAnalyzer(mango.UserDocsTextTests):
         "analyzer": "keyword"
     }
 
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text not supported')
+
     def test_basic(self):
         docs = self.db.find({"$text": "Ramona"})
         assert len(docs) == 0
@@ -53,6 +61,10 @@ class DefaultFieldWithCustomAnalyzer(mango.UserDocsTextTests):
         "analyzer": "keyword"
     }
 
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text not supported')
+
     def test_basic(self):
         docs = self.db.find({"$text": "Ramona"})
         assert len(docs) == 1

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/test/07-text-custom-field-list-test.py
----------------------------------------------------------------------
diff --git a/test/07-text-custom-field-list-test.py b/test/07-text-custom-field-list-test.py
index a019ea2..c1c96db 100644
--- a/test/07-text-custom-field-list-test.py
+++ b/test/07-text-custom-field-list-test.py
@@ -11,11 +11,15 @@
 # the License.
 
 import mango
-
+import unittest
 
 
 class CustomFieldsTest(mango.UserDocsTextTests):
 
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text index is not supported yet')
+
     FIELDS = [
         {"name": "favorites.[]", "type": "string"},
         {"name": "manager", "type": "boolean"},

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/test/08-text-limit-test.py
----------------------------------------------------------------------
diff --git a/test/08-text-limit-test.py b/test/08-text-limit-test.py
index 72c87b5..8478773 100644
--- a/test/08-text-limit-test.py
+++ b/test/08-text-limit-test.py
@@ -12,9 +12,14 @@
 
 import mango
 import limit_docs
+import unittest
 
 class LimitTests(mango.LimitDocsTextTests):
 
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text index is not supported yet')
+
     def test_limit_field(self):
         q = {"$or": [{"user_id" : {"$lt" : 10}}, {"filtered_array.[]": 1}]}
         docs = self.db.find(q, limit=10)

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/93a4bc10/test/09-text-sort-test.py
----------------------------------------------------------------------
diff --git a/test/09-text-sort-test.py b/test/09-text-sort-test.py
index b77ca9a..da58304 100644
--- a/test/09-text-sort-test.py
+++ b/test/09-text-sort-test.py
@@ -11,10 +11,14 @@
 # the License.
 
 import mango
-import user_docs
+import unittest
 
 class SortTests(mango.UserDocsTextTests):
 
+    @classmethod
+    def setUpClass(klass):
+        raise unittest.SkipTest('text index is not supported yet')
+
     def test_number_sort(self):
         q = {"age": {"$gt": 0}}
         docs = self.db.find(q, sort=["age:number"])


Mime
View raw message