Wednesday, November 9, 2011

Programmatic DreReplace in Autonomy 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();
}
}
}

4 comments:

  1. Hi Mahesh,

    I need your help on Autonomy IDOL 7.5.
    Date sort method on autonomy idol7 server is not functioning correctly .

    i want to replace autn_date to dredate.
    i use below link, but its update autn_date to current date.

    http://hostname:4001/DRECHANGEMETA?Type=date&Docs=range=[1,250000]&NewValue=DREDATE

    regards
    Amith

    ReplyDelete
  2. Hi Amith,

    The syntax should http://hostname:4001/DRECHANGEMETA?Type=date&Docs=range=[1,250000]&NewValue= and as mentioned in DateFormatCSVs in the IDOL Configuration and not just DREDATE.

    Thanks
    Mahesh

    ReplyDelete
    Replies
    1. Hi Mahesh,

      Sure, I will try this
      http://hostname:4001/DRECHANGEMETA?Type=date&Docs=range=[1,250000]&NewValue=MM/DD/YYYY

      For time bing I have fixed metadata (autn_date), by export / import index files, which took 48 hours.

      Thanks
      Amith

      Delete
  3. Hi Mahesh,
    I am unable to find the appropriate jars ??
    So ,facing some problem with the drereplcae code.
    Can you help me on this ??

    ReplyDelete