org.gcube.couchbase.helpers
Class ViewHelper
java.lang.Object
org.gcube.couchbase.helpers.ViewHelper
public class ViewHelper
- extends Object
The important thing about the views is that each view has name that is
constructed from the given bucket_name (or "" if not given) the field name
and the datatype of the field.
Couchbase Views are used as index.
Example of a view of field named "title" with datatype string
map :
function (doc, meta) {
if (doc.keys && doc.keys.title) {
for (i = 0 ; i < doc.keys.title.length ; i++) {
emit(doc.keys.title[i], 1);
}
}
}
reduce : _count
Note that each emit gives key and 1 so if we execute the reduce function we
get the number of keys very fast.
If we want to query on the map only we should explicitly disable the reduce
on the Query
- Author:
- Alex Antoniadis
|
Method Summary |
static String |
constructViewName(String bucketName,
String fieldName,
CouchBaseDataTypesHelper.DataType datatype)
|
static String |
constructViewName(String bucketName,
String fieldName,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
|
static void |
createAllIndexes(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
|
static void |
createAllIndexes(com.couchbase.client.CouchbaseClient client,
String bucketName,
String designDocumentName,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
|
static com.couchbase.client.protocol.views.ViewDesign |
getDateView()
|
static com.couchbase.client.protocol.views.ViewDesign |
getDateView(String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getDateView(String bucketName,
String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getFloatView()
|
static com.couchbase.client.protocol.views.ViewDesign |
getFloatView(String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getFloatView(String bucketName,
String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getIntegerView()
|
static com.couchbase.client.protocol.views.ViewDesign |
getIntegerView(String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getIntegerView(String bucketName,
String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getStringView()
|
static com.couchbase.client.protocol.views.ViewDesign |
getStringView(String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getStringView(String bucketName,
String fieldName)
|
static com.couchbase.client.protocol.views.ViewDesign |
getView(String fieldName,
CouchBaseDataTypesHelper.DataType datatype)
|
static com.couchbase.client.protocol.views.ViewDesign |
getView(String bucketName,
String fieldName,
CouchBaseDataTypesHelper.DataType datatype)
|
static void |
main(String[] args)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ViewHelper
public ViewHelper()
createAllIndexes
public static void createAllIndexes(com.couchbase.client.CouchbaseClient client,
String bucketName,
String designDocumentName,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
createAllIndexes
public static void createAllIndexes(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
getIntegerView
public static com.couchbase.client.protocol.views.ViewDesign getIntegerView()
getFloatView
public static com.couchbase.client.protocol.views.ViewDesign getFloatView()
getDateView
public static com.couchbase.client.protocol.views.ViewDesign getDateView()
getStringView
public static com.couchbase.client.protocol.views.ViewDesign getStringView()
constructViewName
public static String constructViewName(String bucketName,
String fieldName,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
constructViewName
public static String constructViewName(String bucketName,
String fieldName,
CouchBaseDataTypesHelper.DataType datatype)
getIntegerView
public static com.couchbase.client.protocol.views.ViewDesign getIntegerView(String fieldName)
getIntegerView
public static com.couchbase.client.protocol.views.ViewDesign getIntegerView(String bucketName,
String fieldName)
getFloatView
public static com.couchbase.client.protocol.views.ViewDesign getFloatView(String fieldName)
getFloatView
public static com.couchbase.client.protocol.views.ViewDesign getFloatView(String bucketName,
String fieldName)
getDateView
public static com.couchbase.client.protocol.views.ViewDesign getDateView(String fieldName)
getDateView
public static com.couchbase.client.protocol.views.ViewDesign getDateView(String bucketName,
String fieldName)
getStringView
public static com.couchbase.client.protocol.views.ViewDesign getStringView(String fieldName)
getStringView
public static com.couchbase.client.protocol.views.ViewDesign getStringView(String bucketName,
String fieldName)
getView
public static com.couchbase.client.protocol.views.ViewDesign getView(String fieldName,
CouchBaseDataTypesHelper.DataType datatype)
getView
public static com.couchbase.client.protocol.views.ViewDesign getView(String bucketName,
String fieldName,
CouchBaseDataTypesHelper.DataType datatype)
main
public static void main(String[] args)
Copyright © 2014. All Rights Reserved.