|
1 | 1 | = MapReduce Views |
2 | | -:description: You can use MapReduce views to create queryable indexes in Couchbase Server. |
| 2 | +:description: Our legacy MapReduce Views Service is best replaced by the scalable Query Service. |
| 3 | +:navtitle: MapReduce Views |
3 | 4 | :page-topic-type: howto |
4 | | -:page-aliases: ROOT:view-queries-with-sdk |
| 5 | +:page-aliases: ROOT:view-queries-with-sdk,ROOT:geo-spatial-views |
5 | 6 |
|
6 | 7 | include::project-docs:partial$attributes.adoc[] |
7 | 8 |
|
8 | 9 | [abstract] |
9 | 10 | {description} |
10 | 11 |
|
11 | 12 | // include::{version-common}@sdk:shared:partial$views.adoc[tag=deprecate] |
12 | | -include::{version-common}@sdk:shared:partial$views.adoc[tag=deprecate] |
13 | 13 |
|
14 | 14 |
|
15 | | -include::{version-common}@sdk:shared:partial$views.adoc[tag=views-intro] |
| 15 | +// option 1 - C++ - redirect to migration page, and add note at end. |
16 | 16 |
|
17 | | -== Querying Views |
| 17 | +// option 2 - most others - this common page, with per-sdk archive link at end. |
18 | 18 |
|
19 | | -View operations are accessible on the `Bucket` API. |
20 | | -Once you have a reference to the bucket you need to at least supply the name of the design document and the name of the view: |
21 | 19 |
|
22 | | -[source,java] |
23 | | ----- |
24 | | -include::example$Views.java[tag=views-simple,indent=0] |
25 | | ----- |
26 | 20 |
|
27 | | -It is important to remember that by default, the SDK will look for a view deployed to the production namespace. |
28 | | -If you want to query one which is still in the development namespace you can do it like this: |
| 21 | +//// |
| 22 | +Views are a legacy service which pre-dates the {name-sdk}. |
| 23 | +Your use case is most likely to be met by the xref:howtos:n1ql-queries-with-sdk.adoc[Query service]. |
| 24 | +//// |
29 | 25 |
|
30 | | -[source,java] |
31 | | ----- |
32 | | -include::example$Views.java[tag=views-dev,indent=0] |
33 | | ----- |
| 26 | +xref:{version-server}@server:learn:views/views-intro.adoc[MapReduce Views] date from the earliest days of Couchbase and although still maintained and supported for legacy use, they are deprecated in Couchbase Server, and will eventually be removed. |
34 | 27 |
|
35 | | -In the same way you can supply all kinds of different options, including the `ViewScanConsistency` which was previously called `Stale`. |
| 28 | +Views are the only service which does not benefit from xref:{version-server}@server:learn:services-and-indexes/services/services.adoc#services-and-multi-dimensional-scaling[Multi-Dimensional Scaling], and is rarely the best choice over, say, xref:howtos:n1ql-queries-with-sdk.adoc[our Query service] if you are starting a fresh application. |
| 29 | +See our discussion document on xref:concept-docs:data-services.adoc[the best service for you to use]. |
36 | 30 |
|
37 | | -[source,java] |
38 | | ----- |
39 | | -include::example$Views.java[tag=views-opts,indent=0] |
40 | | ----- |
| 31 | +CAUTION: If you are provisioning Views on Couchbase Server for a legacy application, _they must run on a |
| 32 | +xref:{version-server}@server:learn:buckets-memory-and-storage/storage-engines.adoc#couchstore[couchstore] bucket_. |
41 | 33 |
|
42 | | -If you have a `reduce` function in your view and you want to call it, make sure to call `.reduce(true)` as well. |
43 | 34 |
|
44 | | -== Working with View Rows |
| 35 | +We will maintain support for Views in the SDKs for so long as it can be used with a supported version of Couchbase Server. |
45 | 36 |
|
46 | | -A `ViewResult` can emit 0 to N view rows. |
47 | | -The available data inside each `ViewRow` depends both on the map function written and if a reduce function is used. |
| 37 | +Information on using MapReduce Views with the SDK can still be accessed in our https://docs-archive.couchbase.com/java-sdk/3.1/howtos/view-queries-with-sdk.html[documentation archive]. |
48 | 38 |
|
49 | | -The structure of a `ViewRow` looks like this: |
50 | | - |
51 | | -[source,java] |
52 | | ----- |
53 | | -include::example$Views.java[tag=view_rows_structure,indent=0] |
54 | | ----- |
55 | | - |
56 | | -Both the `key` and the `value` can be converted into any target type, depending on how you wrote your view function. |
57 | | -Note that the document ID is always a `String`, but it is wrapped in an `Optional` because it is not available if a reduce function is used. |
58 | | - |
59 | | -== Accessing View Metadata |
60 | | - |
61 | | -In addition to the rows the view result contains additional `ViewMetaData`. |
62 | | - |
63 | | -[source,java] |
64 | | ----- |
65 | | -include::example$Views.java[tag=views-meta,indent=0] |
66 | | ----- |
67 | | - |
68 | | -The number of rows is always present, the debug information only if you enable it on the `ViewOptions` as indicated through being wrapped into an `Optional<JsonObject>`. |
0 commit comments