1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-10-26 19:57:22 +08:00
This commit is contained in:
stefanocasazza
2016-09-01 14:57:10 +02:00
parent 117008cfbc
commit a2dba73c24
29 changed files with 317 additions and 258 deletions

View File

@@ -77,13 +77,15 @@ public:
U_RETURN(false);
}
bool search(const UString& _index, const UString& type, const UString& query) { return search(U_STRING_TO_PARAM(_index), U_STRING_TO_PARAM(type), U_STRING_TO_PARAM(query)); }
bool search(const UString& _index, const UString& type, const UString& query)
{ return search(U_STRING_TO_PARAM(_index), U_STRING_TO_PARAM(type), U_STRING_TO_PARAM(query)); }
// Index a document with maybe automatic id creation
bool index(const char* _index, uint32_t index_len, const char* type, uint32_t type_len, const char* id, uint32_t id_len, const char* data, uint32_t data_len)
{
U_TRACE(0, "UElasticSearchClient::index(%.*S,%u,%.*S,%u,%.*S,%u,%.*S,%u)", index_len, _index, index_len, type_len, type, type_len, id_len, id, id_len, data_len, data, data_len)
U_TRACE(0, "UElasticSearchClient::index(%.*S,%u,%.*S,%u,%.*S,%u,%.*S,%u)", index_len, _index, index_len, type_len, type, type_len,
id_len, id, id_len, data_len, data, data_len)
U_INTERNAL_ASSERT_POINTER(data)
U_INTERNAL_ASSERT_POINTER(client)
@@ -124,7 +126,8 @@ public:
bool getDocument(const char* _index, uint32_t index_len, const char* type, uint32_t type_len, const char* key, uint32_t key_len, const char* value, uint32_t value_len)
{
U_TRACE(0, "UElasticSearchClient::getDocument(%.*S,%u,%.*S,%u,%.*S,%u,%.*S,%u)",index_len,_index,index_len,type_len,type,type_len,key_len,key,key_len,value_len,value,value_len)
U_TRACE(0, "UElasticSearchClient::getDocument(%.*S,%u,%.*S,%u,%.*S,%u,%.*S,%u)", index_len, _index, index_len, type_len, type, type_len,
key_len, key, key_len, value_len, value, value_len)
U_INTERNAL_ASSERT_POINTER(client)

View File

@@ -113,8 +113,9 @@ public:
}
#ifndef USE_MONGODB
bool connect(const char* _uri) { return false; }
bool connect(const char* host, unsigned int _port) { return false; }
bool executeBulk(mongoc_bulk_operation_t* bulk) { return false; }
bool connect(const char* host = 0, unsigned int _port = 27017) { return false; }
bool selectCollection(const char* db, const char* name_collection) { return false; }
bool update(uint32_t old_value, const char* key, uint32_t new_value) { return false; }
void updateOneBulk(mongoc_bulk_operation_t* bulk, uint32_t old_value, const char* key, uint32_t new_value) {}
@@ -123,8 +124,6 @@ public:
const char* dump(bool reset) const { return ""; }
# endif
#else
bool connect(const char* uri);
bool insert(bson_t* doc);
bool findOne(const char* json, uint32_t len);
@@ -138,7 +137,10 @@ public:
bool update(uint32_t old_value, const char* key, uint32_t new_value);
bool connect(const char* host = 0, unsigned int _port = 27017); // connect to MongoDB server
// connect to MongoDB server
bool connect(const char* uri);
bool connect(const char* host, unsigned int _port);
// BULK