B4J Programming Press on the image to return to the main documentation page.

jElasticsearch

List of types:

ESClient
ESResponse

ESClient

REST client for Elasticsearch.
Note that all methods are synchronous. The client is expected to be used in server solutions.
Each document is identified by the tuple.

Events:

None

Members:


  BulkInsert (Index As String, Type As String, IdsAndDocuments As List) As ESResponse

  Close

  Delete (Index As String, Type As String, Id As String) As ESResponse

  Exists (Index As String, Type As String, Id As String) As Boolean

  Get (Index As String, Type As String, Id As String) As Map

  Initialize (EventName As String, Hosts As List)

  Insert (Index As String, Type As String, Id As String, Document As Map) As ESResponse

  PerformRawRequest (Method As String, Endpoint As String, QueryParameters As Map, Payload As String) As ESResponse

  Search (Index As String, Type As String, Query As Map) As ESResponse

Members description:

BulkInsert (Index As String, Type As String, IdsAndDocuments As List) As ESResponse
Bulk inserts multiple documents.
IdsAndDocuments is a list (or array) with pairs of ids and documents.
Pass empty strings as the ids to let Elasticsearch create the ids.
Example:
client.BulkInsert("index1", "type1", Array("id1", CreateMap("text": "doc1"), "id2", CreateMap("text": "doc2"))
Close
Closes the client.
Delete (Index As String, Type As String, Id As String) As ESResponse
Deletes the document. An exception will be thrown if there is no such document.
Exists (Index As String, Type As String, Id As String) As Boolean
Checks whether a document with the given Index, Type and Id exists.
Get (Index As String, Type As String, Id As String) As Map
Returns the document. An exception will be thrown if there is no such document.
Initialize (EventName As String, Hosts As List)
Initializes the client and sets the list of hosts.
EventName - Currently there are no events.
Hosts - A list or array with one or more hosts.
Example:
esclient.Initialize("", Array("127.0.0.1:9200"))
Insert (Index As String, Type As String, Id As String, Document As Map) As ESResponse
Inserts or replaces a document. Set the Id to an empty string to create the id automatically.
Returns the server response.
PerformRawRequest (Method As String, Endpoint As String, QueryParameters As Map, Payload As String) As ESResponse
Performs a raw request.
Method - Request method (GET, POST, ...)
EndPoint - Request end point.
QueryParameters - Map of query parameters. Pass Null if not required.
Payload - Body payload. Pass an empty string if not required.
Search (Index As String, Type As String, Query As Map) As ESResponse
Makes a search request.

ESResponse

Holds the server response.

Events:

None

Members:


  Hits As List [read only]

  ResponseAsMap As Map

  ResponseAsString As String

  StatusCode As Int [read only]

Members description:

Hits As List [read only]
Returns the hits. Relevant for search requests.
ResponseAsMap As Map
Parses the JSON response and returns a map with the result.
Note that the map is cached after it is parsed.
ResponseAsString As String
Returns the response as string.
StatusCode As Int [read only]
Returns the request status code (200 in most cases).
Top