summaryrefslogtreecommitdiff
path: root/src/mango/src/mango_idx.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mango/src/mango_idx.erl')
-rw-r--r--src/mango/src/mango_idx.erl27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/mango/src/mango_idx.erl b/src/mango/src/mango_idx.erl
index 6e2abca5c..c2c26958c 100644
--- a/src/mango/src/mango_idx.erl
+++ b/src/mango/src/mango_idx.erl
@@ -72,12 +72,23 @@ get_usable_indexes(Db, Selector, Opts) ->
case lists:filter(UsableFilter, UsableIndexes1) of
[] ->
- ?MANGO_ERROR({no_usable_index, missing_sort_index});
+ mango_sort_error(Db, Opts);
UsableIndexes ->
UsableIndexes
end.
+mango_sort_error(Db, Opts) ->
+ case {fabric_util:is_partitioned(Db), is_opts_partitioned(Opts)} of
+ {false, _} ->
+ ?MANGO_ERROR({no_usable_index, missing_sort_index});
+ {true, true} ->
+ ?MANGO_ERROR({no_usable_index, missing_sort_index_partitioned});
+ {true, false} ->
+ ?MANGO_ERROR({no_usable_index, missing_sort_index_global})
+ end.
+
+
recover(Db) ->
{ok, DDocs0} = mango_util:open_ddocs(Db),
Pred = fun({Props}) ->
@@ -410,12 +421,20 @@ get_idx_partitioned(Db, DDocProps) ->
Default
end.
+is_opts_partitioned(Opts) ->
+ case couch_util:get_value(partition, Opts, <<>>) of
+ <<>> ->
+ false;
+ Partition when is_binary(Partition) ->
+ true
+ end.
+
filter_partition_indexes(Indexes, Opts) ->
- PFilt = case couch_util:get_value(partition, Opts) of
- <<>> ->
+ PFilt = case is_opts_partitioned(Opts) of
+ false ->
fun(#idx{partitioned = P}) -> not P end;
- Partition when is_binary(Partition) ->
+ true ->
fun(#idx{partitioned = P}) -> P end
end,
Filt = fun(Idx) -> type(Idx) == <<"special">> orelse PFilt(Idx) end,