Listing Synced Documents

Before listing the Exalead CloudView index, you need to ensure that changes sent by the connector are taken into account. You can do so by using the sync method of the Push API, or by calling the setCheckpoint method with the sync parameter set to "true".

This page discusses:

Checkpoints

This section explains what is a checkpoint and how to use it.

A checkpoint is a string value associated to a connector. Multiple checkpoints are possible for a connector.

Two methods are used to manipulate the checkpoint: Get and Set methods.

Note: Get operates on Synced state => a Get performed immediately after a Set may not return the same value.

The setCheckpoint method can be used to sync the previous operations by setting the sync parameter to true. It can also be used to know whether the operation status is Searchable. See Operations and states.

Typical use cases of checkpoint operations:

  • Store the last synchronization date of a folder.

  • Store the last eventId in a journal of events.

  • Safely sync to disk previous operations (sync set to true).

  • Allow tracking of operations state to know whether documents are searchable; see Operations and states.

Sync code snippet

Below is a code sample to sync documents at the end of the scan operation.

Java Code

// Example of sync.
public void SyncDocuments(final Date indexingStartDate) {
papi.setCheckpoint(String.valueOf(indexingStartDate), "sync date", true);
}

C# Code

// Example of sync.
        public void SyncDocuments(DateTime indexingStartDate)
{
    papi.SetCheckpoint(indexingStartDate.ToString(), "sync date", true);
}

List documents

Below is a code sample to enumerate the documents of a specified folder.

Java Code

for (final SyncedEntry doc : papi.enumerateSyncedEntries("myfolder", EnumerationMode.RECURSIVE_DOCUMENTS)) {
  System.out.println("uri : " + doc.getUri() + " stamp : " + doc.getStamp());
}
// no need to close Iterator because the end is reached        

C# Code

//Example of the enumeration of document in a specified folder.
public void Enumerate()
{ 
    string rootPath = "myfolder";
    EnumerationMode mode = EnumerationMode.RECURSIVE_DOCUMENTS;
    foreach (SyncedEntry entry in new 
    SyncedEntriesEnumerator(papi.EnumerateSyncedEntries(rootPath, mode)))
    {
        Console.WriteLine("URI = " + entry.Uri + ", Stamp = " + (entry.Stamp ?? "(null)"));
    }
}