public class ElasticsearchClient extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SETTING
The default settings.
|
static String |
ELASTICSEARCH_HOSTS
Default Elasticsearch hosts configuration.
|
static String |
ELASTICSEARCH_SCHEDULE
Default Elasticsearch schedule configuration.
|
protected static com.fasterxml.jackson.databind.ObjectMapper |
MAPPER |
static String |
MAPPINGS
Type mappings for the index this store is related to.
|
static String |
SETTINGS
Settings for the index this store is related to.
|
Constructor and Description |
---|
ElasticsearchClient()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String id,
String document)
This method adds a new document to ElasticSearch.
|
protected <V> void |
addBulk(String id,
String document) |
void |
close()
This method closes the Elasticsearch client.
|
static <V> V |
convertJsonToType(String json,
Class<V> type)
convert type to String.
|
static String |
convertTypeToJson(Object obj)
convert type to String.
|
String |
get(String id)
default implementation of getter returns a simple .json document as String.
|
int |
getBulkSize()
This method returns the _bulkSize.
|
Client |
getElasticsearchClient()
The Elasticsearch client.
|
String |
getHosts()
This method sets the hosts.
|
String |
getIndex()
This method returns the index.
|
long |
getSchedule()
This method returns the schedule.
|
String |
getType()
This method returns the index.
|
void |
init()
Initialize the client.
|
protected void |
initClient(Client client) |
void |
remove(String id)
This method removes the document with the supplied id.
|
void |
setBulkSize(int bulkSize)
This method sets the _bulkSize.
|
void |
setHosts(String hosts)
This method returns the hosts.
|
void |
setIndex(String index)
This method sets the index.
|
void |
setSchedule(long schedule)
This method sets the schedule.
|
void |
setType(String type)
This method sets the type.
|
String |
toString() |
void |
update(String id,
String document)
This method updates the supplied document.
|
protected static final com.fasterxml.jackson.databind.ObjectMapper MAPPER
public static final String ELASTICSEARCH_HOSTS
public static final String ELASTICSEARCH_SCHEDULE
public static final String SETTINGS
public static final String MAPPINGS
public static final String DEFAULT_SETTING
public long getSchedule()
public void setSchedule(long schedule)
schedule
- the schedulepublic String getIndex()
public void setIndex(String index)
index
- The indexpublic String getType()
public void setType(String type)
type
- The typepublic String getHosts()
public void setHosts(String hosts)
hosts
- The hostspublic int getBulkSize()
public void setBulkSize(int bulkSize)
bulkSize
- The bulkSizepublic void init() throws Exception
Exception
- Failed to initialize the clientprotected <V> void addBulk(String id, String document)
V
- id
- document
- public void add(String id, String document) throws Exception
id
- The iddocument
- The documentException
- Failed to addpublic void remove(String id) throws Exception
id
- The idException
- Failed to remove documentpublic void update(String id, String document)
id
- The iddocument
- The documentpublic String get(String id)
id
- The id.public static String convertTypeToJson(Object obj)
obj
- The object to convertpublic static <V> V convertJsonToType(String json, Class<V> type)
V
- type The object typejson
- The json documenttype
- The type of the object to returnpublic Client getElasticsearchClient()
public void close()
Copyright © 2013-2015 JBoss by Red Hat. All Rights Reserved.