Wednesday, November 9, 2011

Programmatic DreReplace in HPE IDOL Server

Whenever a field needs to be updated/replaced with a new one in the IDOL Server index the available options are
1. Re-index the data
2. Use DREREPLACE index command
3. Use DRECHANGEMETA index command if the fields to be changed are autnrank,database,date & expiredate
Re-indexing the data will override the existing data and the entire document will be updated. But re-indexing may not be always possible especially when the volume of data is huge. This is where DREREPLACE will be useful.

I have written DREREPLACE functionality using Autonomy Java ACI API which is available in the Autonomy's Customer Support Portal either as a separate JAR or bundled with Portal-In-A-Box & Retina WAR file.

The latest ACI API version is 4.9.5.
The following jar files needs to be in your classpath i.e., AutonomyACIAPI-4.9.5.jar, commons-codec-1.4.jar, commons-httpclient-3.1.jar, commons-logging-1.1.1.jar.

The DREREPLACE code is

import java.util.ArrayList;
import java.util.List;
import com.autonomy.aci.ActionParameter;
import com.autonomy.aci.exceptions.IndexingException;
import com.autonomy.aci.services.IndexingService;
public class DreReplace {
public static void main(String[] args) {
final String sIDOLServerHostIP = "127.0.0.1";
final int iIDOLServerIndexPort = 9001;
IndexingService indexingService = new IndexingService(
sIDOLServerHostIP, iIDOLServerIndexPort);
List lsActionParameters = new ArrayList();
StringBuilder sbDataFormation = new StringBuilder();
String sDocumentID = "1";
String sDREFieldName0 = "AUTHOR";
String sDREFieldValue0 = "mahesh";
sbDataFormation.append("#DREDOCID ").append(sDocumentID).append("\n");
sbDataFormation.append("#DREFIELDNAME ").append(sDREFieldName0)
.append("\n").append("#DREFIELDVALUE ").append(sDREFieldValue0)
.append("\n");
// this is the repeating part based on the no. of fields to be replaced
sbDataFormation.append("#DREENDDATA\n\n");
try {
indexingService.dreReplace(sbDataFormation.toString(),
lsActionParameters);
} catch (IndexingException indexe) {
indexe.printStackTrace();
}
}
}