GithubHelp home page GithubHelp logo

elasticsearchservice-cfc's Introduction

ElasticSearchService-cfc

DESCRIPTION

CFML wrapper for interacting with Elastic Search. Supports Elastic Search's REST API and TCP connections via Elastic Search's TransportClient.

SUPPORTED CFML ENGINES

  • Adobe ColdFusion 9.0.1
  • Adobe ColdFusion 10
  • Adobe ColdFusion 11
  • Lucee 4.5

REQUIRED DEPENDENCIES (HTTP OR TCP)

REQUIRED DEPENDENCIES FOR TCP

  • elasticsearch jar
  • lucene-core jar

OPTIONAL DEPENDENCIES FOR TCP

ASSUMPTIONS

  • aggregation results must use key name aggregation_results
  • aggregation hits must use key name agg_hits

Service Constructor when using HTTP

ElasticSearchService = new ElasticSearchService(
	api_base_uri=""
);

Service Constructor when using TCP without JavaLoader

ElasticSearchService = new ElasticSearchService(
	cluster_name="",
	master_node=""
);

Service Constructor when using TCP with JavaLoader

ElasticSearchService = new ElasticSearchService(
	cluster_name="",
	master_node="",
	javaloaderMapping="",
	loadPaths=[
		"path/to/elasticsearch-1.6.0.jar",
		"path/to/lucene-core-4.10.4.jar"
	]
);

HTTP Search Example

response = ElasticSearchService.search(
	protocol = "HTTP",
	index = "dev",
	type = "product",
	query_string = '{"timeout": 30,"_source": ["label","retail_unit_price"],"from": 0,"size": 10,"sort":[{"retail_unit_price": {"order": "asc"}},{"label": {"order": "asc"}}],"query":{"filtered":{"filter":{"and":[{"bool":{"must":{"term":{"store_group_id":9}}}},{"bool":{"must":{"range":{"date_expected":{"lte":"2016-01-27"}}}}},{"bool":{"should":{"term":{"default_product_category_id":97}}}}]}}}}'		
);

TCP Search Example

response = ElasticSearchService.search(
	protocol = "TCP",
	index = "dev",
	type = "product",
	query_string = '{"timeout": 30,"_source": ["label","retail_unit_price"],"from": 0,"size": 10,"sort":[{"retail_unit_price": {"order": "asc"}},{"label": {"order": "asc"}}],"query":{"filtered":{"filter":{"and":[{"bool":{"must":{"term":{"store_group_id":9}}}},{"bool":{"must":{"range":{"date_expected":{"lte":"2016-01-27"}}}}},{"bool":{"should":{"term":{"default_product_category_id":97}}}}]}}}}'		
);

HTTP Suggest Example

response = ElasticSearchService.suggest(
	protocol = "HTTP",
	context_field_name = "brand_id",
	context_field_value = "123",
	index = "dev",
	size = 10,
	text='My Awesome Product',
	fuzziness="auto"		
);

TCP Suggest Example

response = ElasticSearchService.suggest(
	protocol = "TCP",
	context_field_name = "brand_id",
	context_field_value = "123",
	index = "dev",
	size = 10,
	text='My Awesome Product',
	fuzziness="auto"		
);

Basic Query String Search Example

{
	"timeout": 30,
	"_source": ["label", "retail_unit_price"],
	"from": 0,
	"size": 10,
	"sort": [{
		"retail_unit_price": {
			"order": "asc"
		}
	}, {
		"label": {
			"order": "asc"
		}
	}],
	"query": {
		"filtered": {
			"filter": {
				"and": [{
					"bool": {
						"must": {
							"term": {
								"store_group_id": 9
							}
						}
					}
				}, {
					"bool": {
						"must": {
							"range": {
								"date_expected": {
									"lte": "2016-01-27"
								}
							}
						}
					}
				}, {
					"bool": {
						"should": {
							"term": {
								"default_product_category_id": 97
							}
						}
					}
				}]
			}
		}
	}
}

Aggregation Query String Search Example

{
	"timeout": 30,
	"_source": [],
	"from": 0,
	"size": 10,
	"sort": [{
		"retail_unit_price": {
			"order": "asc"
		}
	}, {
		"label": {
			"order": "asc"
		}
	}],
	"query": {
		"filtered": {
			"filter": {
				"and": [{
					"bool": {
						"must": {
							"term": {
								"brand_id": 123
							}
						}
					}
				}
			}
		}
	},
	"aggs": {
		"aggregation_results": {
			"terms": {
				"field": "label",
				"collect_mode": "depth_first",
				"min_doc_count": 1,
				"shard_min_doc_count": 0,
				"size": 10,
				"order": [{
					"retail_unit_price": "asc"
				}, {
					"label": "asc"
				}]
			},
			"aggs": {
				"agg_hits": {
					"top_hits": {
						"_source": [],
						"size": 1,
						"sort": [{
							"retail_unit_price": {
								"order": "asc"
							}
						}, {
							"label": {
								"order": "asc"
							}
						}]
					}
				},
				"retail_unit_price": {
					"min": {
						"script": "doc.retail_unit_price"
					}
				},
				"label": {
					"min": {
						"script": "doc.label"
					}
				}
			}
		}
	}
}

elasticsearchservice-cfc's People

Contributors

wellercs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.