Skip to content

Add support for queries in /{db}/_all_docs POST#1032

Merged
wohali merged 1 commit intoapache:masterfrom
cloudant:issue-820-add-queries-for_all_docs
Jan 18, 2018
Merged

Add support for queries in /{db}/_all_docs POST#1032
wohali merged 1 commit intoapache:masterfrom
cloudant:issue-820-add-queries-for_all_docs

Conversation

@jiangphcn
Copy link
Copy Markdown
Contributor

@jiangphcn jiangphcn commented Nov 30, 2017

Overview

Allow to POST to /{db}/_all_docs and specify a queries list in the body, the same way you can do with a regular MapReduce view, like

curl -u foo:bar -H "Content-Type: application/json" -X POST -d @multiple_queries.json http://localhost:15984/db97/_all_docs
{"results":[
{"total_rows":30,"rows":[
{"id":"point2","key":"point2","value":{"rev":"1-d942f0ce01647aa0f46518b213b5628e"}},
{"id":"point3","key":"point3","value":{"rev":"1-721fead6e6c8d811a225d5a62d08dfd0"}}
]},
{"total_rows":30,"offset":2,"rows":[
{"id":"point11","key":"point11","value":{"rev":"1-ffb6c2ae737918f8f911e1fce668333e"}},
{"id":"point12","key":"point12","value":{"rev":"1-c32d315f69ce72128244a60d0cbe4628"}},
{"id":"point13","key":"point13","value":{"rev":"1-a9b955ca17f553398cd877629e803c5d"}},
{"id":"point14","key":"point14","value":{"rev":"1-2f2aa0db2a8c35754e7ab2308940f60c"}},
{"id":"point15","key":"point15","value":{"rev":"1-247191505d8fa6b4b9dc426321987b17"}}
]}
]}

multiple_queries.json looks like

    {
        "queries": [
            {
                "keys": [
                    "point2",
                    "point3"
                ]
            },
            {
                "limit": 5,
                "skip": 2
            }
        ]
    }

This also can work against /{db}/_design_docs and /{db}/_local_docs endpoints.

Testing recommendations

make check skip_deps+=couch_epi apps=chttpd tests=all_test_

======================== EUnit ========================
chttpd security tests
Application crypto was left running!
  chttpd_security_tests:118: should_allow_admin_db_compaction...[0.002 s] ok
  chttpd_security_tests:133: should_disallow_anonymous_db_compaction...ok
  chttpd_security_tests:141: should_disallow_db_member_db_compaction...ok
  chttpd_security_tests:144: should_allow_db_admin_db_compaction...[0.003 s] ok
  chttpd_security_tests:154: should_allow_admin_view_compaction...[0.010 s] ok
  chttpd_security_tests:169: should_disallow_anonymous_view_compaction...ok
  chttpd_security_tests:172: should_allow_admin_db_view_cleanup...[0.002 s] ok
  chttpd_security_tests:187: should_disallow_anonymous_db_view_cleanup...ok
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
  [done in 5.013 s]
chttpd db tests
  chttpd_db_test:79: should_return_ok_true_on_bulk_update...[0.058 s] ok
  chttpd_db_test:106: should_accept_live_as_an_alias_for_continuous...[0.178 s] ok
  chttpd_db_test:121: should_return_404_for_delete_att_on_notadoc...[0.005 s] ok
  chttpd_db_test:143: should_return_409_for_del_att_without_rev...[0.040 s] ok
  chttpd_db_test:161: should_return_200_for_del_att_with_rev...[0.058 s] ok
  chttpd_db_test:182: should_return_409_for_put_att_nonexistent_rev...[0.012 s] ok
  chttpd_db_test:197: should_succeed_on_all_docs_with_queries_keys...[0.256 s] ok
  chttpd_db_test:211: should_succeed_on_all_docs_with_queries_limit_skip...[0.241 s] ok
  chttpd_db_test:226: should_succeed_on_all_docs_with_multiple_queries...[0.231 s] ok
  chttpd_db_test:244: should_succeed_on_design_docs_with_multiple_queries...[0.229 s] ok
  chttpd_db_test:262: should_fail_on_multiple_queries_with_keys_and_queries...[0.257 s] ok
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
  [done in 3.655 s]
chttpd db max_document_size tests
  chttpd_db_doc_size_tests:84: post_single_doc...ok
  chttpd_db_doc_size_tests:92: put_single_doc...ok
  chttpd_db_doc_size_tests:101: bulk_doc...ok
  chttpd_db_doc_size_tests:127: put_post_doc_attach_inline...ok
  chttpd_db_doc_size_tests:128: put_post_doc_attach_inline...ok
  chttpd_db_doc_size_tests:129: put_post_doc_attach_inline...ok
  chttpd_db_doc_size_tests:130: put_post_doc_attach_inline...ok
  chttpd_db_doc_size_tests:152: put_multi_part_related...ok
  chttpd_db_doc_size_tests:153: put_multi_part_related...ok
  chttpd_db_doc_size_tests:177: post_multi_part_form...ok
  chttpd_db_doc_size_tests:178: post_multi_part_form...ok
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
  [done in 1.225 s]
=======================================================
  All 30 tests passed.
==> rel (eunit)
==> couchdb (eunit)

Related Issues or Pull Requests

issue #820

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;

@jiangphcn jiangphcn force-pushed the issue-820-add-queries-for_all_docs branch 2 times, most recently from 789bb2d to fe16e0c Compare December 4, 2017 06:08
@jiangphcn jiangphcn changed the title [WIP]Add support for queries in /{db}/_all_docs POST Add support for queries in /{db}/_all_docs POST Dec 4, 2017
@jiangphcn jiangphcn force-pushed the issue-820-add-queries-for_all_docs branch 4 times, most recently from e776453 to 0e849e8 Compare December 8, 2017 08:09
@wohali
Copy link
Copy Markdown
Member

wohali commented Jan 16, 2018

Thanks!!!

+1 once you resolve the conflict. :)

@jiangphcn
Copy link
Copy Markdown
Contributor Author

Thanks @wohali. Already addressed conflict in commit 7aec581.

@jiangphcn jiangphcn force-pushed the issue-820-add-queries-for_all_docs branch from 7aec581 to d1fa4b4 Compare January 18, 2018 00:08
@jiangphcn
Copy link
Copy Markdown
Contributor Author

I already rebased again. @wohali or any other committer, can you help merge it to master branch? Thanks

@wohali wohali merged commit 0fd9509 into apache:master Jan 18, 2018
@wohali
Copy link
Copy Markdown
Member

wohali commented Jan 18, 2018

Done! Feel free to do the documentation too if you have time :)

Thank you again.

@jiangphcn
Copy link
Copy Markdown
Contributor Author

Thanks wohali. Will update document later.

@jiangphcn
Copy link
Copy Markdown
Contributor Author

@wohali Hey Joan, documentation update PR is apache/couchdb-documentation#241.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants