forked from jasonfill/ColdFusion-ElasticSearch-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElasticSearchClient.cfc
80 lines (65 loc) · 2.76 KB
/
ElasticSearchClient.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
component accessors="true" extends="Base" {
property name="OutputUtils";
property name="LoggingUtil";
property name="ClusterManager" type="ClusterManager";
public ElasticSearchClient function init(required ClusterManager ClusterManager){
variables.ClusterManager = arguments.ClusterManager;
variables.OutputUtils = new OutputUtils();
return this;
}
public FilterBuilder function filterBuilder(){
return new search.filters.FilterBuilder();
}
public QueryBuilder function queryBuilder(){
return new search.queries.QueryBuilder();
}
public FacetBuilder function facetBuilder(){
return new search.facets.FacetBuilder();
}
public SearchRequest function prepareSearch(){
var search = new requests.SearchRequest(argumentCollection=arguments);
search.setClusterManager(getClusterManager());
return search;
}
public IndexRequest function prepareIndex(string index="", string type="", string id=""){
var index = new requests.IndexRequest(ClusterManager=getClusterManager());
index.setIndex(arguments.index);
index.setType(arguments.type);
index.setId(arguments.id);
return index;
}
public MappingRequest function prepareMapping(required string index, required string type, required elasticsearch.indexing.TypeMapping typeMapping){
var index = new requests.MappingRequest(ClusterManager=getClusterManager());
index.setIndex(arguments.index);
index.setType(arguments.type);
index.setBody(typeMapping.getJson());
return index;
}
public BulkRequest function prepareBulk(boolean Transactional=false){
return new requests.BulkRequest(Transactional=Arguments.Transactional, ClusterManager=getClusterManager(), OutputUtils=getOutputUtils(), ElasticSearchClient=this);
}
public MultiGetRequest function prepareMultiGet(){
return new requests.MultiGetRequest(ClusterManager=getClusterManager(), OutputUtils=getOutputUtils());
}
public GetRequest function prepareGet(string index="", string type="_all", string id=""){
var get = new requests.GetRequest(ClusterManager=getClusterManager());
get.setIndex(arguments.index);
get.setType(arguments.type);
get.setId(arguments.id);
return get;
}
public DeleteRequest function prepareDelete(required string index, string type="", string id=""){
var delete = new requests.DeleteRequest(ClusterManager=getClusterManager());
delete.setIndex(arguments.index);
delete.setType(arguments.type);
delete.setId(arguments.id);
return delete;
}
public GenericRequest function prepareRequest(required string uri, required string method, required string body){
var genericRequest = new requests.GenericRequest(ClusterManager=getClusterManager());
genericRequest.setUri(arguments.uri);
genericRequest.setMethod(arguments.method);
genericRequest.setBody(arguments.body);
return genericRequest;
}
}