You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2015/09/10 02:34:04 UTC
[02/26] couchdb-mango git commit: Remove text search limit
Remove text search limit
Rather than use hardcoded values for text search limit,
we fit the value within the configurable Dreyfus max_limit
parameter.
FogBugzID: 44968
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/29eddf01
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/29eddf01
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/29eddf01
Branch: refs/heads/master
Commit: 29eddf0115f4a73d920acbdcfb59cf232e98448a
Parents: fc1e36f
Author: Tony Sun <to...@cloudant.com>
Authored: Tue Aug 25 10:12:05 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Tue Aug 25 10:12:05 2015 -0700
----------------------------------------------------------------------
src/mango_cursor_text.erl | 17 +++++++----------
test/08-text-limit-test.py | 9 +++++----
2 files changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/29eddf01/src/mango_cursor_text.erl
----------------------------------------------------------------------
diff --git a/src/mango_cursor_text.erl b/src/mango_cursor_text.erl
index c774c82..ec83240 100644
--- a/src/mango_cursor_text.erl
+++ b/src/mango_cursor_text.erl
@@ -49,10 +49,8 @@ create(Db, Indexes, Selector, Opts0) ->
Opts = unpack_bookmark(Db#db.name, Opts0),
- % Limit the result set size to 50 for Clouseau's
- % sake. We may want to revisit this.
- Limit0 = couch_util:get_value(limit, Opts, 50),
- Limit = if Limit0 < 50 -> Limit0; true -> 50 end,
+ DreyfusLimit = get_dreyfus_limit(),
+ Limit = erlang:min(DreyfusLimit, couch_util:get_value(limit, Opts, 50)),
Skip = couch_util:get_value(skip, Opts, 0),
Fields = couch_util:get_value(fields, Opts, all_fields),
@@ -282,12 +280,11 @@ update_query_args(CAcc) ->
get_limit(CAcc) ->
- Total = CAcc#cacc.limit + CAcc#cacc.skip,
- if
- Total < 25 -> 25;
- Total > 100 -> 100;
- true -> Total
- end.
+ erlang:min(get_dreyfus_limit(), CAcc#cacc.limit + CAcc#cacc.skip).
+
+
+get_dreyfus_limit() ->
+ list_to_integer(config:get("dreyfus", "max_limit", "200")).
get_json_docs(DbName, Hits) ->
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/29eddf01/test/08-text-limit-test.py
----------------------------------------------------------------------
diff --git a/test/08-text-limit-test.py b/test/08-text-limit-test.py
index 8478773..45c0bc4 100644
--- a/test/08-text-limit-test.py
+++ b/test/08-text-limit-test.py
@@ -48,11 +48,12 @@ class LimitTests(mango.LimitDocsTextTests):
# We reach our cap here of 50
def test_limit_field5(self):
- q = {"$or": [{"user_id" : {"$lt" : 100}}, {"filtered_array.[]": 1}]}
- docs = self.db.find(q, limit=55)
- assert len(docs) == 50
+ q = {"age": {"$exists": True}}
+ docs = self.db.find(q, limit=250)
+ print len(docs)
+ assert len(docs) == 75
for d in docs:
- assert d["user_id"] < 100
+ assert d["age"] < 100
def test_limit_skip_field1(self):
q = {"$or": [{"user_id" : {"$lt" : 100}}, {"filtered_array.[]": 1}]}