Constructor classes, interfaces, and methods

This topic describes the document constructor Java™ API, C++ API, and server APIs.

Client Java API

TextSearchServer
createCollection (String collectionId,String physicalPath,
                  String collectionConstructorName,String comment)
Collection
setConstructorConfiguration (String constructorName, 
                             byte[] configData);
IndexableDocument
setConstructorName (String constructorName);
setConstructedDocumentData (byte[] docData);
Tip: Calling these two methods is optional. If the collection has a constructor defined and no constructor is specified for the document, the collection constructor is used for the document.

Client C++ API

namespace and const declarations were removed from the code examples for readability.

Collection class:
Collection (constructor)
Create a collection with default constructor. Use this method if you want to use the same Constructor for most documents in the collection. To use this method, you must add the constructor name to the colProps parameter. The relevant header is Constants::DOCUMENT_CONSTRUCTOR_NAME.

// Prepare properties with a collection ID and a constructor name:
ExtendedProperties props;
props.putProperty(Collection::COLLECTION_ID, "collectionId");
props.putProperty(Constants::DOCUMENT_CONSTRUCTOR_NAME, 
                  "myConstructorName");

// Create the collection:
Collection *collection = new Collection(props, *_sessionConfig); 
setConstructor Configuration
Sets the collection constructor configuration. The constructorName class defines the constructor name and theconfigData class is a buffer that is passed to the constructor as is.
void setConstructorConfiguration(const String &constructorName,
             const byte_t *configData, const uint32_t dataLength);
RawDocument class:
setConstructor Name
Sets the constructor name for this document. If specified, the constructor is used for the document, whether or not a collection constructor is defined.
void setConstructorName(const String& constructorName);
setConstructed DocumentData
Sets the document data that will be passed to the constructor, for example, information used by the constructor to retrieve the document.
void setConstructedDocumentData(
                     const byte_t *constructedDocumentData, 
                     const uint32_t dataLength);

Server APIs

IConstructor
initialize(String constructorName, String customConstructorRegistryInfo 
/*from config file*/);
setConfiguration (String collectionName, byte[] constructorConfigData
/*from setConstructorConfig*/);
populateDocuments (IConstructedDocument[] arrayOfConstructedDocuments,
IFilterService service); 
// Array is not more than the batch size defined in the XML configuration
   file; service is document filtering service.
IConstructedDocument
Serves as a public interface for the internal document.
byte[] getDocId(); // returns the document ID which is used by indexer
String getCollectionId() returns the collection ID a document is indexed
into byte[] getConstructedDocumentData (); returns byte[] which is passed 
setInputStream(InputStream inputStream);
addMetaData(Metadata metadata) adds meta-data name-value field which are
indexed in addition to document content
addConstructorMessage(IMessage messsage); in case of an error, a message
is added to the array of error messages
setKnownLanguage(String language); known language which will be used for 
language processing
setDefaultLanguage(String language) default language which will be used for
language processing as a fall-back language
setContentType(ContentType contentType);
Note: Content type can be: PLAIN_TEXT, XML,BINARY,UNKNOWN
ContentType  getContentType();
IMessage
Represents an error message.
String getMessageCode() returns message code
getFormattedMessage(String msg,Locale lc)
Throwable getException()
MessageType getType()