Elasticlient
Public Member Functions | List of all members
elasticlient::SameIndexBulkData Class Reference

#include <bulk.h>

Inheritance diagram for elasticlient::SameIndexBulkData:
Inheritance graph
[legend]
Collaboration diagram for elasticlient::SameIndexBulkData:
Collaboration graph
[legend]

Public Member Functions

 SameIndexBulkData (const std::string &indexName, std::size_t size=100)
 
virtual std::string indexName () const override
 Return index name set during contruction.
 
bool indexDocument (const std::string &docType, const std::string &id, const std::string &doc)
 
bool indexDocument (const std::string &docType, const std::string &id, const std::string &doc, bool validate)
 
bool createDocument (const std::string &docType, const std::string &id, const std::string &doc)
 
bool createDocument (const std::string &docType, const std::string &id, const std::string &doc, bool validate)
 
bool updateDocument (const std::string &docType, const std::string &id, const std::string &doc)
 
bool updateDocument (const std::string &docType, const std::string &id, const std::string &doc, bool validate)
 
void clear ()
 Clear bulk (size() == 0 after this).
 
virtual bool empty () const override
 Return true if bulk has no data inside.
 
virtual std::size_t size () const override
 Return number of documents inside the bulk.
 
virtual std::string body () const override
 Return elasticsearch bulk request data.
 

Detailed Description

Data collector for the bulk operation. All bulk data must be determined to be send to same index. Class produces document body for elasticsearch /_bulk request.

Constructor & Destructor Documentation

◆ SameIndexBulkData()

elasticlient::SameIndexBulkData::SameIndexBulkData ( const std::string &  indexName,
std::size_t  size = 100 
)
explicit

Create Bulk data collector with desired size. Size of the bulk is not limiting the client to insert more elements into bulk.

Parameters
indexNameName of the index all data will be send to.

Member Function Documentation

◆ createDocument() [1/2]

bool elasticlient::SameIndexBulkData::createDocument ( const std::string &  docType,
const std::string &  id,
const std::string &  doc 
)

Add create document request to the bulk.

Parameters
docTypedocument type (as specified in mapping).
iddocument ID, for auto-generated ID use empty string.
docJson document to index. Must not contain newline char.
Returns
true if bulk has reached its desired capacity.

◆ createDocument() [2/2]

bool elasticlient::SameIndexBulkData::createDocument ( const std::string &  docType,
const std::string &  id,
const std::string &  doc,
bool  validate 
)

Add create document request to the bulk.

Parameters
docTypedocument type (as specified in mapping).
iddocument ID, for auto-generated ID use empty string.
docJson document to index. Must not contain newline char.
validatechecks whether string contains a newline.
Returns
true if bulk has reached its desired capacity.
Todo:
Merge with createDocument() above with validate=true when ABI breaks.

◆ indexDocument() [1/2]

bool elasticlient::SameIndexBulkData::indexDocument ( const std::string &  docType,
const std::string &  id,
const std::string &  doc 
)

Add index document request to the bulk.

Parameters
docTypedocument type (as specified in mapping).
iddocument ID, for auto-generated ID use empty string.
docJson document to index. Must not contain newline char.
Returns
true if bulk has reached its desired capacity.

◆ indexDocument() [2/2]

bool elasticlient::SameIndexBulkData::indexDocument ( const std::string &  docType,
const std::string &  id,
const std::string &  doc,
bool  validate 
)

Add index document request to the bulk.

Parameters
docTypedocument type (as specified in mapping).
iddocument ID, for auto-generated ID use empty string.
docJson document to index. Must not contain newline char.
validatechecks whether string contains a newline.
Returns
true if bulk has reached its desired capacity.
Todo:
Merge with indexDocument() above with validate=true when ABI breaks.

◆ updateDocument() [1/2]

bool elasticlient::SameIndexBulkData::updateDocument ( const std::string &  docType,
const std::string &  id,
const std::string &  doc 
)

Add update document request to the bulk.

Parameters
docTypedocument type (as specified in mapping).
iddocument ID, for auto-generated ID use empty string.
docJson document to index. Must not contain newline char.
Returns
true if bulk has reached its desired capacity.

◆ updateDocument() [2/2]

bool elasticlient::SameIndexBulkData::updateDocument ( const std::string &  docType,
const std::string &  id,
const std::string &  doc,
bool  validate 
)

Add update document request to the bulk.

Parameters
docTypedocument type (as specified in mapping).
iddocument ID, for auto-generated ID use empty string.
docJson document to index. Must not contain newline char.
validatechecks whether string contains a newline.
Returns
true if bulk has reached its desired capacity.
Todo:
Merge with updateDocument() above with validate=true when ABI breaks.

The documentation for this class was generated from the following file: