Skip to content

Commit

Permalink
Release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
romansanchez committed May 17, 2015
1 parent 1ec250f commit 24094fb
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 33 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.2.0 - May 17, 2015
- Add support for delayed searches
- Simplify configs
- Plugin support
- Update documentation
- Bug fixes/cleanup

## 1.1.1 - Dec 9, 2014
- Add support for lucene queries
- Add support for specifying protocol
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Roman Sanchez
Copyright (c) 2015 Roman Sanchez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ Calaca
Calaca is a beautiful, easy to use, search UI for Elasticsearch. It's made for you if you need to do quick searches for your documents and don't need anything hard to setup, use.
- Quick, easy and instant search
- Looks good
- Minimum configs required
- Displays hits count and time taken for query
- Supports pagination
- Full support for lucene queries(boolean, range, etc)
- Simple configs
- Query metrics(hits counts, time took)
- Pagination
- Lucene queries(boolean, range, etc)
- Plugin install or stand-alone

Demo
=========
Expand All @@ -24,12 +25,11 @@ Get Started
In **config.js** change the configs to match your Elasticsearch cluster.
```js
/* Configs */
var indexName = "name"; //Ex: twitter
var docType = "type"; //Ex: tweet
var maxResultsSize = 10;
var host = "localhost"; //Ex: ec2-123-aws.com
var port = 9200;
var protocol = ""; //Default: same as browser
url: "http://localhost:9200" //Cluster http url
index_name: "twitter" //Index name or comma-separated list
type: "tweet" //Type
size: 10 //Number of results displayed at a time
search_delay: 500 //Delay between actual search request
```

In **index.html** append to ```result.``` the field name you want to show from your es document.
Expand All @@ -39,6 +39,13 @@ Using dot notation, you can access nested fields like such ```result.transaction
<p>{{result.description}}</p>
```

Plugin
----
You can also install as an elasticsearch plugin. Same config updates are required to **config.js** and **index.html**.
```bash
bin/plugin -i romansanchez/Calaca
```

Styling
----
You can easily change the look and feel of Calaca by implementing the below CSS classes.
Expand All @@ -50,11 +57,15 @@ You can easily change the look and feel of Calaca by implementing the below CSS
.result
```

Common Issues
----
* No 'Access-Control-Allow-Origin' header is present on the requested resource.
* Add ```http.cors.enabled: true``` to your ```elasticsearch.yml```

Version
----

1.1.1
1.2.0

Author
----
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Calaca",
"version": "1.1.1",
"version": "1.2.0",
"homepage": "https://github.com/romansanchez/Calaca",
"authors": [
"Roman Sanchez http://romansanchez.me"
Expand Down
2 changes: 1 addition & 1 deletion css/calaca.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* http://romansanchez.me
* @rooomansanchez
*
* v1.1.1
* v1.2.0
* MIT License
*/

Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<header class='jumbotron'>
<h1 class='title'>Calaca</h1>
<div class='search-box-container'>
<input type='text' class='search-box' placeholder='Search' autofocus ng-model='query' ng-change='search(0)'>
<input type='text' class='search-box' placeholder='Search' autofocus ng-model='query' ng-change='delayedSearch(0)'>
</div>
</header>

<!-- Listing of search results -->
<main class='results-container'>
<section class='results-info'>
<p id='response-details'>{{(hits | number) || 0}} {{resultsString || 'results'}} ({{timeTook || 0}}ms)</p>
<p id='response-details'>{{(hits | number) || 0}} {{resultsLabel || 'results'}} ({{(timeTook || 0)}}ms)</p>
<p ng-show='paginationEnabled()' id='pagination-details'>Showing {{paginationLowerBound}} - {{paginationUpperBound}}</p>
</section>
<section class='results'>
Expand Down
2 changes: 1 addition & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* http://romansanchez.me
* @rooomansanchez
*
* v1.1.1
* v1.2.0
* MIT License
*/

Expand Down
24 changes: 17 additions & 7 deletions js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@
* http://romansanchez.me
* @rooomansanchez
*
* v1.1.1
* v1.2.0
* MIT License
*/

/* Configs */
var indexName = "name"; //Ex: twitter
var docType = "type"; //Ex: tweet
var maxResultsSize = 10;
var host = "localhost"; //Ex: http://ec2-123-aws.com
var port = 9200;
var protocol = ""; //Default: same as browser
/**
*
* url - Cluster http url
* index_name - Index name or comma-separated list
* type - Type
* size - Number of results to display at a time when pagination is enabled.
* search_delay - Delay between actual search request. Reduces number of queries to cluster by not making a request on each keystroke.
*/

var CALACA_CONFIGS = {
url: "",
index_name: "",
type: "",
size: 10,
search_delay: 500
}
11 changes: 10 additions & 1 deletion js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* http://romansanchez.me
* @rooomansanchez
*
* v1.1.1
* v1.2.0
* MIT License
*/

Expand All @@ -22,6 +22,15 @@ Calaca.controller('calacaCtrl', ['calacaService', '$scope', '$location', functio
$scope.offset = 0;

var paginationTriggered;
var maxResultsSize = CALACA_CONFIGS.size;
var searchTimeout;

$scope.delayedSearch = function(mode) {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(function() {
$scope.search(mode)
}, CALACA_CONFIGS.search_delay);
}

//On search, reinitialize array, then perform search and load results
$scope.search = function(m){
Expand Down
20 changes: 12 additions & 8 deletions js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@
* http://romansanchez.me
* @rooomansanchez
*
* v1.1.1
* v1.2.0
* MIT License
*/

/* Service to Elasticsearch */
Calaca.factory('calacaService', ['$q', 'esFactory', '$location', function($q, elasticsearch, $location){

//Set defaults if host and port aren't configured
var esHost = (host.length > 0 ) ? host : $location.host();
var esProtocol = (protocol.length > 0 ) ? protocol : $location.protocol();
//Set default url if not configured
CALACA_CONFIGS.url = (CALACA_CONFIGS.url.length > 0) ? CALACA_CONFIGS.url : $location.protocol() + '://' +$location.host() + ":9200";

var client = elasticsearch({ host: esProtocol + '://' + esHost + ":" + port });
var client = elasticsearch({ host: CALACA_CONFIGS.url });

var search = function(query, mode, offset){

var deferred = $q.defer();

if (query.length == 0) {
deferred.resolve({ timeTook: 0, hitsCount: 0, hits: [] });
return deferred.promise;
}

client.search({
"index": indexName,
"type": docType,
"index": CALACA_CONFIGS.index_name,
"type": CALACA_CONFIGS.type,
"body": {
"size": maxResultsSize,
"size": CALACA_CONFIGS.size,
"from": offset,
"query": {
"query_string": {
Expand Down

0 comments on commit 24094fb

Please sign in to comment.