public class QueryHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
QueryHelper.OrderBy |
| Constructor and Description |
|---|
QueryHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addExcludedFields(List<ArrayList<org.gcube.indexmanagement.bdbwrapper.BDBGcqlQueryContainer.SingleTerm>> queries,
List<String> projections)
Adds the fields that may be in searchables with wildcards but not appear
in projections
|
static Collection<Map<String,String>> |
applyProjection(Map<String,Object> docs,
List<String> projections,
boolean distinct)
Performs projection on the given documents.
|
static com.couchbase.client.protocol.views.Query |
createOneOperantQuery(Operator op,
Object value)
Creates a 1-operant Query from the given operator and value
|
static com.couchbase.client.protocol.views.Query |
createOneOperantQuery(com.couchbase.client.protocol.views.Query query,
Operator op,
Object value)
Creates a 1-operant Query from the given operator and value
|
static com.couchbase.client.protocol.views.Query |
createTwoOperantQuery(Operator op,
Object value1,
Object value2)
Creates a 2-operant Query from the given operators and values
|
static com.couchbase.client.protocol.views.Query |
createTwoOperantQuery(Operator op1,
Object value1,
Operator op2,
Object value2)
Creates a 2-operant Query from the given operators and values
|
static String |
deleteOrderBy(String query,
String orderByField,
QueryHelper.OrderBy orderBy)
Deletes order by clause from query
|
static void |
dummyQuery(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
String viewName)
Performs a dummy query with stale value FALSE in order to force index to
be recreated
|
static List<String> |
getExcludedFields(List<org.gcube.indexmanagement.bdbwrapper.BDBGcqlQueryContainer.SingleTerm> terms)
Excludes the fields with the wildcards
|
static Map<String,List<org.gcube.couchbase.helpers.Relation>> |
getKeys(String queryString)
Returns a Map that contains the Relations per key that are extracted from
the queryString Relations contain the operator and the value for each
key.
|
static QueryHelper.OrderBy |
getOrderBy(String query)
Returns the order by condition (ASC, DESC) or ASC if not given
|
static String |
getOrderByField(String query)
Returns the order by field
|
static List<String> |
getViewResponse(com.couchbase.client.protocol.views.ViewResponse vr)
Returns a list of the keys of the matching documents of the ViewResponse
|
static Map<String,String> |
getViewResponseKeyValues(com.couchbase.client.protocol.views.ViewResponse vr) |
static Long |
keyCount(com.couchbase.client.CouchbaseClient client,
String bucketName,
String designDocumentName,
Set<String> fields,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
Returns the total number of keys of all fields.
|
static void |
main(String[] args) |
static Map<String,Object> |
multiGetCouchBase(com.couchbase.client.CouchbaseClient client,
Collection<String> ids,
boolean distinct)
Returns a Map of
|
static Map<String,Object> |
multiGetCouchBase(com.couchbase.client.CouchbaseClient client,
Collection<String> ids,
boolean distinct,
int numOfResults)
Returns a Map of
|
static void |
printQueryDate(com.couchbase.client.protocol.views.ViewResponse vr) |
static String |
pruneQuery(List<org.gcube.indexmanagement.bdbwrapper.BDBGcqlQueryContainer.SingleTerm> terms)
Returns a string that is the representations of the terms given but
excludes the fields with the wildcard
|
static List<String> |
queryCouchBase(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
String viewName,
Operator op,
Object key)
Returns only the keys and the matching docs (not the document).
|
static List<String> |
queryCouchBase(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
String viewName,
Operator op,
Object startKey,
Object endKey)
Returns only the keys and the matching docs (not the document).
|
static List<String> |
queryCouchBase(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
String viewName,
Operator op1,
Object key1,
Operator op2,
Object key2)
Returns only the keys and the matching docs (not the document).
|
static Long |
queryCountCouchBase(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
String viewName)
Returns the total number of keys of all fields.
|
static Long |
queryCountCouchBase(com.couchbase.client.CouchbaseClient client,
String bucketName,
String designDocumentName,
String fieldName,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
Returns the total number of keys of all fields.
|
static List<String> |
queryRelations(com.couchbase.client.CouchbaseClient client,
String bucketName,
String designDocumentName,
Map<String,List<org.gcube.couchbase.helpers.Relation>> relations,
Map<String,CouchBaseDataTypesHelper.DataType> keys)
Returns all the ids that match the given Relations in a list.
|
static List<String> |
queryString(com.couchbase.client.CouchbaseClient client,
String bucketName,
String designDocumentName,
Map<String,CouchBaseDataTypesHelper.DataType> keys,
String queryString)
Returns all the ids that match the given queryString in a list.
|
static Object |
singleGetCouchBase(com.couchbase.client.CouchbaseClient client,
String id)
Returns a document that its key matches the id given
|
static Map<String,List<org.gcube.couchbase.helpers.Relation>> |
validateAndSimplifyKeys(Map<String,List<org.gcube.couchbase.helpers.Relation>> keys)
Performs a validation on a Map that contains the Relations per key.
|
public static String pruneQuery(List<org.gcube.indexmanagement.bdbwrapper.BDBGcqlQueryContainer.SingleTerm> terms)
terms - public static List<String> getExcludedFields(List<org.gcube.indexmanagement.bdbwrapper.BDBGcqlQueryContainer.SingleTerm> terms)
terms - public static void addExcludedFields(List<ArrayList<org.gcube.indexmanagement.bdbwrapper.BDBGcqlQueryContainer.SingleTerm>> queries, List<String> projections)
queries - projections - public static String getOrderByField(String query)
query - public static QueryHelper.OrderBy getOrderBy(String query)
query - public static String deleteOrderBy(String query, String orderByField, QueryHelper.OrderBy orderBy)
query - public static void dummyQuery(com.couchbase.client.CouchbaseClient client,
String designDocumentName,
String viewName)
client - designDocumentName - viewName - public static Collection<Map<String,String>> applyProjection(Map<String,Object> docs, List<String> projections, boolean distinct)
docs - projections - public static List<String> queryCouchBase(com.couchbase.client.CouchbaseClient client, String designDocumentName, String viewName, Operator op, Object startKey, Object endKey)
client - designDocumentName - viewName - startKey - endKey - public static List<String> queryCouchBase(com.couchbase.client.CouchbaseClient client, String designDocumentName, String viewName, Operator op1, Object key1, Operator op2, Object key2)
client - designDocumentName - viewName - op1 - key1 - op2 - key2 - public static List<String> queryCouchBase(com.couchbase.client.CouchbaseClient client, String designDocumentName, String viewName, Operator op, Object key)
client - designDocumentName - viewName - op - key - public static List<String> getViewResponse(com.couchbase.client.protocol.views.ViewResponse vr)
vr - public static Object singleGetCouchBase(com.couchbase.client.CouchbaseClient client, String id)
client - id - public static Map<String,Object> multiGetCouchBase(com.couchbase.client.CouchbaseClient client, Collection<String> ids, boolean distinct)
client - ids - distinct - public static Map<String,Object> multiGetCouchBase(com.couchbase.client.CouchbaseClient client, Collection<String> ids, boolean distinct, int numOfResults)
client - ids - distinct - public static Map<String,List<org.gcube.couchbase.helpers.Relation>> getKeys(String queryString) throws Exception
queryString - Exceptionpublic static Map<String,List<org.gcube.couchbase.helpers.Relation>> validateAndSimplifyKeys(Map<String,List<org.gcube.couchbase.helpers.Relation>> keys) throws Exception
keys - Exceptionpublic static List<String> queryString(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocumentName, Map<String,CouchBaseDataTypesHelper.DataType> keys, String queryString) throws Exception
client - bucketName - designDocumentName - keys - queryString - Exceptionpublic static List<String> queryRelations(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocumentName, Map<String,List<org.gcube.couchbase.helpers.Relation>> relations, Map<String,CouchBaseDataTypesHelper.DataType> keys) throws Exception
client - bucketName - designDocumentName - keys - Exceptionpublic static Long keyCount(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocumentName, Set<String> fields, Map<String,CouchBaseDataTypesHelper.DataType> keys) throws Exception
client - bucketName - designDocumentName - fields - keys - Exceptionpublic static Long queryCountCouchBase(com.couchbase.client.CouchbaseClient client, String bucketName, String designDocumentName, String fieldName, Map<String,CouchBaseDataTypesHelper.DataType> keys) throws Exception
client - bucketName - designDocumentName - fieldName - keys - Exceptionpublic static Long queryCountCouchBase(com.couchbase.client.CouchbaseClient client, String designDocumentName, String viewName) throws Exception
client - designDocumentName - viewName - Exceptionpublic static com.couchbase.client.protocol.views.Query createTwoOperantQuery(Operator op1, Object value1, Operator op2, Object value2)
op1 - value1 - op2 - value2 - public static com.couchbase.client.protocol.views.Query createTwoOperantQuery(Operator op, Object value1, Object value2)
op - value1 - value2 - public static com.couchbase.client.protocol.views.Query createOneOperantQuery(Operator op, Object value)
op - value - public static com.couchbase.client.protocol.views.Query createOneOperantQuery(com.couchbase.client.protocol.views.Query query,
Operator op,
Object value)
query - op - value - public static void printQueryDate(com.couchbase.client.protocol.views.ViewResponse vr)
public static Map<String,String> getViewResponseKeyValues(com.couchbase.client.protocol.views.ViewResponse vr)
Copyright © 2014. All Rights Reserved.