Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Dreyfus" (Erlang side of Search) to CouchDB #2037

Merged
merged 83 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
e2dd274
First public release of Dreyfus
rnewson Jul 20, 2015
4b90276
Match new couchdb naming convention
rnewson Aug 4, 2015
c729966
properly rename this time
rnewson Aug 4, 2015
d5c5509
Plug into couchdb 2.0 with epi handlers
rnewson Aug 24, 2015
9c563b5
fix error handling for _search_analyze
rnewson Aug 24, 2015
0e1f788
Add ejson_body
Aug 17, 2015
f69a572
Merge pull request #1 from cloudant-labs/50663-add-ejson-body
Aug 25, 2015
1cb551a
remove cloudant_util function call
rnewson Aug 26, 2015
29ba95c
Allow binaries for _search_analyze
rnewson Sep 1, 2015
cee7626
Handle errors when opening an index
davisp Sep 2, 2015
dd5f000
Merge pull request #3 from cloudant-labs/2-handle-open-errors
rnewson Sep 11, 2015
80ba863
Use couch_crypto
rnewson Sep 29, 2015
008051d
Merge pull request #4 from cloudant-labs/52884-use-couch-crypto
rnewson Sep 29, 2015
574cb44
Update to new couch_epi API
iilyak Oct 1, 2015
5f11337
Merge pull request #5 from cloudant-labs/simplify_couch_epi
iilyak Oct 1, 2015
d125b71
Add new metric to track the search request time.
brkolla May 9, 2016
95df984
Merge pull request #6 from cloudant-labs/66031-add-metrics-dreyfus-ht…
brkolla May 10, 2016
dd49ff9
Remove trailing spaces
eiri Jun 8, 2016
fb8c85f
Make handle_search_req return proper response
eiri Jun 8, 2016
6c6d5ab
Merge pull request #7 from cloudant-labs/67924-fix-handlers-response
eiri Jun 8, 2016
944389b
Don't crash on invalid ddoc
eiri Jul 12, 2016
2356160
Merge pull request #8 from cloudant-labs/69570-fix-invalid-ddoc-crash
eiri Jul 12, 2016
4390bb5
Improve search logging
Oct 3, 2016
a8ea666
Merge pull request #9 from cloudant-labs/75421-improve-search-logging
rnewson Oct 3, 2016
a018d1f
Tolerate open_int failure
rnewson Nov 22, 2016
9607250
Merge pull request #10 from cloudant-labs/77650-open-int-crash
rnewson Nov 22, 2016
3c1001d
Fix shard replacement
Apr 11, 2017
5fbbe3e
Merge pull request #15 from cloudant-labs/84146_fix_shard_replacement
mayya-sharipova Apr 12, 2017
bc2f94b
Add new end point to get disk size information for search index
brkolla May 31, 2017
d838881
Merge pull request #17 from cloudant-labs/87336-add-disk_size-end-point
brkolla Jun 6, 2017
ad3f55a
Remove couch_crypto
iilyak Aug 1, 2017
fb7b680
Merge pull request #20 from cloudant-labs/remove-couch_crypto
iilyak Aug 2, 2017
dde3f04
Rename search index directory in place when database is deleted
jiangphcn Sep 7, 2017
e29303c
Remove public db record
davisp Feb 16, 2017
3f5ba2b
Merge pull request #23 from cloudant-labs/COUCHDB-3288-remove-public-…
davisp Sep 27, 2017
30b0556
Merge pull request #22 from cloudant-labs/86318-rename-search-indexes…
jiangphcn Oct 11, 2017
5eef719
Update to use pluggable storage engine APIs
davisp Feb 16, 2017
df88b1c
Merge pull request #26 from cloudant-labs/COUCHDB-3287-pluggable-stor…
davisp Feb 28, 2018
b9805be
Add ability to black list indexes (#27)
tonysun83 Aug 15, 2018
a4f3ca3
fix typo to noreply (#29)
tonysun83 Aug 16, 2018
2712350
Improve search blacklist
jiangphcn Aug 30, 2018
9ab3010
Merge pull request #31 from cloudant-labs/109229-improve-blacklist
jiangphcn Aug 30, 2018
bf4b2cd
Update to use new purge API
chguocloudant Nov 30, 2016
0f1be2f
Merge pull request #14 from cloudant-labs/COUCHDB-3326-clustered-purge
jiangphcn Sep 28, 2018
10c1015
use updated_on instead of timestamp_utc in local purge doc
jiangphcn Oct 25, 2018
89368b2
Merge pull request #32 from cloudant-labs/COUCHDB-3326-use-updated_on
jiangphcn Oct 25, 2018
e1730b8
Avoid calls to `fabric:design_docs/1`
davisp Dec 5, 2018
b755e72
Merge pull request #37 from cloudant-labs/fix-get-minimum-purge-seq
davisp Dec 7, 2018
1c18b79
Fix function_clause caused by malformed accumulator
rnewson Dec 14, 2018
1bdca62
Merge pull request #39 from cloudant-labs/fix-function-clause-load-docs
rnewson Dec 14, 2018
96877dc
Remove deprecated clauses
davisp Oct 30, 2018
092194d
Support partitioned queries
davisp Oct 30, 2018
74e246d
Add partition search tests
garrensmith Dec 4, 2018
3893301
Implement separate limits for partitioned queries
jiangphcn Dec 4, 2018
0c59190
Merge pull request #34 from cloudant-labs/feature/database-partitions
davisp Jan 18, 2019
5c1bb7e
Support search with limit using POST method
jiangphcn Jan 28, 2019
0413baa
Merge pull request #40 from cloudant-labs/search-using-limit-with-post
jiangphcn Jan 29, 2019
8c7f5f5
Reject multiple conflicting values of `partition`
davisp Feb 6, 2019
5b8ecb3
Merge pull request #41 from cloudant-labs/partition-parameters
davisp Feb 6, 2019
57ea522
Fixed typo
davisp Feb 7, 2019
228ae8a
fix function_clause (#42)
tonysun83 Feb 13, 2019
1ba7e98
Always send a binary when calling clouseau_rpc:delete
rnewson Feb 16, 2019
03d8331
Merge pull request #43 from cloudant-labs/116712-fix-delete
rnewson Feb 17, 2019
7df7402
Avoid dreyfus_index_manager for _search_disk_size.
theburge Mar 7, 2019
33ee6c2
Merge pull request #44 from cloudant-labs/avoid-dreyfus-index-manager…
theburge Mar 7, 2019
383c96a
add stats for search
garrensmith Mar 28, 2019
7083d1e
Merge pull request #45 from cloudant-labs/add-pricing-for-pq
garrensmith Mar 28, 2019
75d86c4
Use dedicated search IOQ channel
chewbranca Apr 12, 2019
48edbf3
Add IOQ2 metric for search traffic
chewbranca Apr 12, 2019
2fcfb6b
Merge pull request #46 from cloudant-labs/use-dedicated-search-ioq-ch…
chewbranca Apr 18, 2019
996f1cc
adjust metric for io_queue-search
jiangphcn May 10, 2019
45469b9
Merge pull request #47 from cloudant-labs/adjust-io_queue-search
jiangphcn May 14, 2019
80e3cd8
Address EPI's startup use of dreyfus_config
kocolosk May 20, 2019
6f1b8d3
Add 'src/dreyfus/' from commit '80e3cd8111bda643686d9165ea6afa99d0d33…
kocolosk May 25, 2019
8e6fa8b
Add dreyfus.js from cloudant/couchdb@c323f1943
kocolosk May 20, 2019
b1e0037
Ensure Dreyfus JS code is included in build
kocolosk May 20, 2019
1513d48
Add Dreyfus to Erlang release
kocolosk May 20, 2019
2650981
Merge branch 'master' into dreyfus-by-default
kocolosk Jun 14, 2019
93275c3
Improve detection of Search subsystem
kocolosk Jun 15, 2019
6f95fb3
Improve error message on Clouseau connection fail
kocolosk Jun 19, 2019
7dbd4d5
Further improve detection of Search system
kocolosk Jun 19, 2019
0d32708
Document config settings related to search system
kocolosk Jun 20, 2019
c517618
Merge branch 'master' into dreyfus-by-default
kocolosk Jun 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ SubDirs = [
"src/couch_peruser",
"src/couch_tests",
"src/ddoc_cache",
"src/dreyfus",
"src/fabric",
"src/global_changes",
"src/mango",
Expand Down
1 change: 1 addition & 0 deletions rel/apps/couch_epi.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
couch_db_epi,
chttpd_epi,
couch_index_epi,
dreyfus_epi,
global_changes_epi,
mango_epi,
mem3_epi,
Expand Down
29 changes: 29 additions & 0 deletions rel/overlay/etc/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,32 @@ min_priority = 2.0

[smoosh.ratio_views]
min_priority = 2.0

[dreyfus]
; The name and location of the Clouseau Java service required to
; enable Search functionality.
; name = clouseau@127.0.0.1

; CouchDB will try to re-connect to Clouseau using a bounded
; exponential backoff with the following number of iterations.
; retry_limit = 5

; The default number of results returned from a global search query.
; limit = 25

; The default number of results returned from a search on a partition
; of a database.
; limit_partitions = 2000

; The maximum number of results that can be returned from a global
; search query (or any search query on a database without user-defined
; partitions). Attempts to set ?limit=N higher than this value will
; be rejected.
; max_limit = 200

; The maximum number of results that can be returned when searching
; a partition of a database. Attempts to set ?limit=N higher than this
; value will be rejected. If this config setting is not defined,
; CouchDB will use the value of `max_limit` instead. If neither is
; defined, the default is 2000 as stated here.
; max_limit_partitions = 2000
2 changes: 2 additions & 0 deletions rel/reltool.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
couch_event,
couch_peruser,
ddoc_cache,
dreyfus,
ets_lru,
fabric,
folsom,
Expand Down Expand Up @@ -99,6 +100,7 @@
{app, couch_event, [{incl_cond, include}]},
{app, couch_peruser, [{incl_cond, include}]},
{app, ddoc_cache, [{incl_cond, include}]},
{app, dreyfus, [{incl_cond, include}]},
{app, ets_lru, [{incl_cond, include}]},
{app, fabric, [{incl_cond, include}]},
{app, folsom, [{incl_cond, include}]},
Expand Down
62 changes: 62 additions & 0 deletions share/server/dreyfus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.

var Dreyfus = (function() {

var index_results = []; // holds temporary emitted values during index

function handleIndexError(err, doc) {
if (err == "fatal_error") {
throw(["error", "map_runtime_error", "function raised 'fatal_error'"]);
} else if (err[0] == "fatal") {
throw(err);
}
var message = "function raised exception " + err.toSource();
if (doc) message += " with doc._id " + doc._id;
log(message);
};

return {
index: function(name, value, options) {
if (typeof name !== 'string') {
throw({name: 'TypeError', message: 'name must be a string not ' + typeof name});
}
if (name.substring(0, 1) === '_') {
throw({name: 'ReservedName', message: 'name must not start with an underscore'});
}
if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') {
throw({name: 'TypeError', message: 'value must be a string, a number or boolean not ' + typeof value});
}
if (options && typeof options !== 'object') {
throw({name: 'TypeError', message: 'options must be an object not ' + typeof options});
}
index_results.push([name, value, options || {}]);
},

indexDoc: function(doc) {
Couch.recursivelySeal(doc);
var buf = [];
for each (fun in State.funs) {
index_results = [];
try {
fun(doc);
buf.push(index_results);
} catch (err) {
handleIndexError(err, doc);
buf.push([]);
}
}
print(JSON.stringify(buf));
}

}
})();
2 changes: 2 additions & 0 deletions share/server/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function create_sandbox() {
sandbox.send = Render.send;
sandbox.getRow = Render.getRow;
sandbox.isArray = isArray;
sandbox.index = Dreyfus.index;
} catch (e) {
var sandbox = {};
}
Expand Down Expand Up @@ -114,6 +115,7 @@ var Loop = function() {
"add_fun" : State.addFun,
"add_lib" : State.addLib,
"map_doc" : Views.mapDoc,
"index_doc": Dreyfus.indexDoc,
"reduce" : Views.reduce,
"rereduce" : Views.rereduce
};
Expand Down
4 changes: 4 additions & 0 deletions src/dreyfus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ebin/
.*.sw?
test/elixir/_build
test/elixir/deps
202 changes: 202 additions & 0 deletions src/dreyfus/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2015 IBM Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Loading