public abstract class EventHub extends EventHubBase
Learn more
The example demonstrates a typical usage of the class.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
String query = "Einstein";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.getEvents().ErrorOccurred.add(new EventHandler<IndexErrorEventArgs>() {
public void invoke(Object sender, IndexErrorEventArgs args) {
System.out.println(args.getMessage());
}
});
// Indexing documents from the specified folder
index.add(documentsFolder);
// Searching in the index
SearchResult result = index.search(query);
Constructor and Description |
---|
EventHub() |
raiseErrorOccurredPublic, raiseImagePreparingPublic, raisePasswordRequiredPublic
protected EventHandler<OperationFinishedEventArgs> OperationFinishedDelegate
public final Event<EventHandler<OperationFinishedEventArgs>> OperationFinished
Occurs when an index operation is finished.
The example demonstrates how to use the event.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.getEvents().OperationFinished.add(new EventHandler<OperationFinishedEventArgs>() {
public void invoke(Object sender, OperationFinishedEventArgs args) {
System.out.println("Operation finished: " + args.getOperationType());
System.out.println("Message: " + args.getMessage());
System.out.println("Index folder: " + args.getIndexFolder());
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
System.out.println("Time: " + df.format(args.getTime()));
}
});
// Indexing documents from the specified folder
index.add(documentsFolder);
protected EventHandler<IndexErrorEventArgs> ErrorOccurredDelegate
public final Event<EventHandler<IndexErrorEventArgs>> ErrorOccurred
Occurs when an error happens during an index operation.
The example demonstrates how to use the event.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
String query = "Einstein";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.getEvents().ErrorOccurred.add(new EventHandler<IndexErrorEventArgs>() {
public void invoke(Object sender, IndexErrorEventArgs args) {
System.out.println(args.getMessage());
}
});
// Indexing documents from the specified folder
index.add(documentsFolder);
// Searching in the index
SearchResult result = index.search(query);
protected EventHandler<OperationProgressEventArgs> OperationProgressChangedDelegate
public final Event<EventHandler<OperationProgressEventArgs>> OperationProgressChanged
Occurs when the progress of the indexing or update operation changes.
The example demonstrates how to use the event.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.getEvents().OperationProgressChanged.add(new EventHandler<OperationProgressEventArgs>() {
public void invoke(Object sender, OperationProgressEventArgs args) {
System.out.println("Last processed: " + args.getLastDocumentPath());
System.out.println("Result: " + args.getLastDocumentStatus());
System.out.println("Processed documents: " + args.getTotalDocuments());
System.out.println("Progress percentage: " + args.getProgressPercentage());
}
});
// Indexing documents from the specified folder
index.add(documentsFolder);
protected EventHandler<OptimizationProgressEventArgs> OptimizationProgressChangedDelegate
Occurs when the progress of the optimization operation changes.
public final Event<EventHandler<OptimizationProgressEventArgs>> OptimizationProgressChanged
protected EventHandler<PasswordRequiredEventArgs> PasswordRequiredDelegate
public final Event<EventHandler<PasswordRequiredEventArgs>> PasswordRequired
Occurs when a document requires password for opening.
The example demonstrates how to use the event.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.getEvents().PasswordRequired.add(new EventHandler<PasswordRequiredEventArgs>() {
public void invoke(Object sender, PasswordRequiredEventArgs args) {
if (args.getDocumentFullPath().endsWith("ProtectedDocument.pdf")) {
args.setPassword("123456");
}
}
});
// Indexing documents from the specified folder
index.add(documentsFolder);
protected EventHandler<FileIndexingEventArgs> FileIndexingDelegate
public final Event<EventHandler<FileIndexingEventArgs>> FileIndexing
Occurs when a document is going to be indexed.
The example demonstrates how to use the event.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.getEvents().FileIndexing.add(new EventHandler<FileIndexingEventArgs>() {
public void invoke(Object sender, FileIndexingEventArgs args) {
if (args.getDocumentFullPath().endsWith("Protected.pdf")) {
args.setAdditionalFields(new DocumentField[] {
new DocumentField("Tags", "Protected")
});
}
if (!args.getDocumentFullPath().toLowerCase().contains("important")) {
args.setSkipIndexing(true);
}
}
});
// Indexing documents from the specified folder
index.add(documentsFolder);
protected EventHandler<ImagePreparingEventArgs> ImagePreparingDelegate
public final Event<EventHandler<ImagePreparingEventArgs>> ImagePreparing
protected EventHandler<BaseIndexEventArgs> StatusChangedDelegate
public final Event<EventHandler<BaseIndexEventArgs>> StatusChanged
Occurs when the index status changes.
The example demonstrates how to use the event.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Subscribing to the event
index.getEvents().StatusChanged.add(new EventHandler<BaseIndexEventArgs>() {
public void invoke(Object sender, BaseIndexEventArgs args) {
if (args.getStatus() != IndexStatus.InProgress) {
// A notification of the operation completion should be here
}
}
});
// Setting the flag for asynchronous indexing
IndexingOptions options = new IndexingOptions();
options.setAsync(true);
// Asynchronous indexing documents from the specified folder
// The method terminates before the operation completes
index.add(documentsFolder, options);
protected EventHandler<SearchPhaseEventArgs> SearchPhaseCompletedDelegate
public final Event<EventHandler<SearchPhaseEventArgs>> SearchPhaseCompleted
Occurs when the search phase is completed.
The example demonstrates how to use the event.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Indexing documents from the specified folder
index.add(documentsFolder);
// Subscribing to the event
index.getEvents().SearchPhaseCompleted.add(new EventHandler<SearchPhaseEventArgs>() {
public void invoke(Object sender, SearchPhaseEventArgs args) {
System.out.println("Search phase: " + args.getSearchPhase());
System.out.println("Words: " + args.getWords().length);
}
});
SearchOptions options = new SearchOptions();
options.setUseSynonymSearch(true);
options.setUseWordFormsSearch(true);
options.getFuzzySearch().setEnabled(true);
options.setUseHomophoneSearch(true);
SearchResult result = index.search("Einstein", options);