If you want to convert your source data into an unsupported Elasticsearch data type, write Java routines to tell MapR-DB how to perform conversions.
You specify how to convert your data by writing a Java class that extends an interface provided by MapR. You then create a JAR file that contains this class and place the file anywhere on the source MapR cluster. When you set up replication from your source MapR-DB tables to destination indexes, you will use a configuration file to tell MapR-DB where the JAR file is located.
To specify how to convert source data to custom mapping definitions, follow these steps:
- Create a Java class to convert your data into the data types that you established in Elasticsearch.This class must implement the interface
- In the
pom.xmlfile for your Java project, add this dependency:
- Create a JAR file that contains your class and the
pom.xmlfile. You can give the JAR file any name that you prefer.
- Place the JAR file anywhere in the local Linux file system on the MapR node where you plan to run the
maprcli table replica elasticsearch autosetupcommand to map the source MapR table to the Elasticsearch type. You will point to this file when you configure the source MapR cluster for table replication to your Elasticsearch types.
- Create the destination type for each source table for which you want to use the custom mapping. Use Elasticsearch’s
What to do next
If you have not done so already, register your Elasticsearch cluster or clusters with your MapR source cluster.
If you have already registered your Elasticsearch cluster, configure replication to types in Elasticsearch.
If you ever change how your source data is mapped to Elasticsearch data types, you must restart the MapR gateways that you are using for indexing. Follow these steps:
- Pause indexing of your MapR-DB source tables. To get a list of the Elasticsearch types that are used for each source table, use the
maprcli table replica elasticsearch listcommand. For each Elasticsearch type, issue the
maprcli table replica elasticsearch pausecommand to pause indexing.
- Restart the MapR gateways that you are using for indexing. See the section "On clusters where gateways are running" in Configuring MapR Gateways for Table Replication or Indexing.
- Resume indexing by issuing the command
maprcli table replica elasticsearch resumefor each Elasticsearch type that you are indexing your data in.