Class ElasticIndexWriter
- java.lang.Object
-
- org.apache.nutch.indexwriter.elastic.ElasticIndexWriter
-
- All Implemented Interfaces:
Configurable
,IndexWriter
,Pluggable
public class ElasticIndexWriter extends Object implements IndexWriter
Sends NutchDocuments to a configured Elasticsearch index.
-
-
Field Summary
-
Fields inherited from interface org.apache.nutch.indexer.IndexWriter
X_POINT_ID
-
-
Constructor Summary
Constructors Constructor Description ElasticIndexWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.elasticsearch.action.bulk.BulkProcessor.Listener
bulkProcessorListener()
Generates a default BulkProcessor.Listenervoid
close()
void
commit()
void
delete(String key)
Map<String,Map.Entry<String,Object>>
describe()
ReturnsMap
with the specific parameters the IndexWriter instance can take.Configuration
getConf()
protected org.elasticsearch.client.RestHighLevelClient
makeClient(IndexWriterParams parameters)
Generates a RestHighLevelClient with the hosts givenvoid
open(Configuration conf, String name)
void
open(IndexWriterParams parameters)
Initializes the internal variables from a given index writer configuration.void
setConf(Configuration conf)
void
update(NutchDocument doc)
void
write(NutchDocument doc)
-
-
-
Method Detail
-
open
public void open(Configuration conf, String name) throws IOException
- Specified by:
open
in interfaceIndexWriter
- Parameters:
conf
- Nutch configurationname
- target name of theIndexWriter
to be opened- Throws:
IOException
- Some exception thrown by some writer.
-
open
public void open(IndexWriterParams parameters) throws IOException
Initializes the internal variables from a given index writer configuration.- Specified by:
open
in interfaceIndexWriter
- Parameters:
parameters
- Params from the index writer configuration.- Throws:
IOException
- Some exception thrown by writer.
-
makeClient
protected org.elasticsearch.client.RestHighLevelClient makeClient(IndexWriterParams parameters) throws IOException
Generates a RestHighLevelClient with the hosts given- Parameters:
parameters
- implementation specificIndexWriterParams
- Returns:
- an initialized
RestHighLevelClient
- Throws:
IOException
- if there is an error reading theIndexWriterParams
-
bulkProcessorListener
protected org.elasticsearch.action.bulk.BulkProcessor.Listener bulkProcessorListener()
Generates a default BulkProcessor.Listener- Returns:
BulkProcessor.Listener
-
write
public void write(NutchDocument doc) throws IOException
- Specified by:
write
in interfaceIndexWriter
- Throws:
IOException
-
delete
public void delete(String key) throws IOException
- Specified by:
delete
in interfaceIndexWriter
- Throws:
IOException
-
update
public void update(NutchDocument doc) throws IOException
- Specified by:
update
in interfaceIndexWriter
- Throws:
IOException
-
commit
public void commit() throws IOException
- Specified by:
commit
in interfaceIndexWriter
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceIndexWriter
- Throws:
IOException
-
describe
public Map<String,Map.Entry<String,Object>> describe()
ReturnsMap
with the specific parameters the IndexWriter instance can take.- Specified by:
describe
in interfaceIndexWriter
- Returns:
- The values of each row. It must have the form <KEY,<DESCRIPTION,VALUE>>.
-
setConf
public void setConf(Configuration conf)
- Specified by:
setConf
in interfaceConfigurable
-
getConf
public Configuration getConf()
- Specified by:
getConf
in interfaceConfigurable
-
-