Skip to content

Commit 24094fb

Browse files
committed
Release 1.2.0
1 parent 1ec250f commit 24094fb

10 files changed

Lines changed: 74 additions & 33 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.2.0 - May 17, 2015
4+
- Add support for delayed searches
5+
- Simplify configs
6+
- Plugin support
7+
- Update documentation
8+
- Bug fixes/cleanup
9+
310
## 1.1.1 - Dec 9, 2014
411
- Add support for lucene queries
512
- Add support for specifying protocol

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Roman Sanchez
3+
Copyright (c) 2015 Roman Sanchez
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Calaca
44
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.
55
- Quick, easy and instant search
66
- Looks good
7-
- Minimum configs required
8-
- Displays hits count and time taken for query
9-
- Supports pagination
10-
- Full support for lucene queries(boolean, range, etc)
7+
- Simple configs
8+
- Query metrics(hits counts, time took)
9+
- Pagination
10+
- Lucene queries(boolean, range, etc)
11+
- Plugin install or stand-alone
1112

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

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

42+
Plugin
43+
----
44+
You can also install as an elasticsearch plugin. Same config updates are required to **config.js** and **index.html**.
45+
```bash
46+
bin/plugin -i romansanchez/Calaca
47+
```
48+
4249
Styling
4350
----
4451
You can easily change the look and feel of Calaca by implementing the below CSS classes.
@@ -50,11 +57,15 @@ You can easily change the look and feel of Calaca by implementing the below CSS
5057
.result
5158
```
5259

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

5465
Version
5566
----
5667

57-
1.1.1
68+
1.2.0
5869

5970
Author
6071
----

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Calaca",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"homepage": "https://github.com/romansanchez/Calaca",
55
"authors": [
66
"Roman Sanchez http://romansanchez.me"

css/calaca.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* http://romansanchez.me
55
* @rooomansanchez
66
*
7-
* v1.1.1
7+
* v1.2.0
88
* MIT License
99
*/
1010

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
<header class='jumbotron'>
1616
<h1 class='title'>Calaca</h1>
1717
<div class='search-box-container'>
18-
<input type='text' class='search-box' placeholder='Search' autofocus ng-model='query' ng-change='search(0)'>
18+
<input type='text' class='search-box' placeholder='Search' autofocus ng-model='query' ng-change='delayedSearch(0)'>
1919
</div>
2020
</header>
2121

2222
<!-- Listing of search results -->
2323
<main class='results-container'>
2424
<section class='results-info'>
25-
<p id='response-details'>{{(hits | number) || 0}} {{resultsString || 'results'}} ({{timeTook || 0}}ms)</p>
25+
<p id='response-details'>{{(hits | number) || 0}} {{resultsLabel || 'results'}} ({{(timeTook || 0)}}ms)</p>
2626
<p ng-show='paginationEnabled()' id='pagination-details'>Showing {{paginationLowerBound}} - {{paginationUpperBound}}</p>
2727
</section>
2828
<section class='results'>

js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* http://romansanchez.me
55
* @rooomansanchez
66
*
7-
* v1.1.1
7+
* v1.2.0
88
* MIT License
99
*/
1010

js/config.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@
44
* http://romansanchez.me
55
* @rooomansanchez
66
*
7-
* v1.1.1
7+
* v1.2.0
88
* MIT License
99
*/
1010

1111
/* Configs */
12-
var indexName = "name"; //Ex: twitter
13-
var docType = "type"; //Ex: tweet
14-
var maxResultsSize = 10;
15-
var host = "localhost"; //Ex: http://ec2-123-aws.com
16-
var port = 9200;
17-
var protocol = ""; //Default: same as browser
12+
/**
13+
*
14+
* url - Cluster http url
15+
* index_name - Index name or comma-separated list
16+
* type - Type
17+
* size - Number of results to display at a time when pagination is enabled.
18+
* search_delay - Delay between actual search request. Reduces number of queries to cluster by not making a request on each keystroke.
19+
*/
20+
21+
var CALACA_CONFIGS = {
22+
url: "",
23+
index_name: "",
24+
type: "",
25+
size: 10,
26+
search_delay: 500
27+
}

js/controllers.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* http://romansanchez.me
55
* @rooomansanchez
66
*
7-
* v1.1.1
7+
* v1.2.0
88
* MIT License
99
*/
1010

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

2424
var paginationTriggered;
25+
var maxResultsSize = CALACA_CONFIGS.size;
26+
var searchTimeout;
27+
28+
$scope.delayedSearch = function(mode) {
29+
clearTimeout(searchTimeout);
30+
searchTimeout = setTimeout(function() {
31+
$scope.search(mode)
32+
}, CALACA_CONFIGS.search_delay);
33+
}
2534

2635
//On search, reinitialize array, then perform search and load results
2736
$scope.search = function(m){

js/services.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,32 @@
44
* http://romansanchez.me
55
* @rooomansanchez
66
*
7-
* v1.1.1
7+
* v1.2.0
88
* MIT License
99
*/
1010

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

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

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

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

2221
var deferred = $q.defer();
2322

23+
if (query.length == 0) {
24+
deferred.resolve({ timeTook: 0, hitsCount: 0, hits: [] });
25+
return deferred.promise;
26+
}
27+
2428
client.search({
25-
"index": indexName,
26-
"type": docType,
29+
"index": CALACA_CONFIGS.index_name,
30+
"type": CALACA_CONFIGS.type,
2731
"body": {
28-
"size": maxResultsSize,
32+
"size": CALACA_CONFIGS.size,
2933
"from": offset,
3034
"query": {
3135
"query_string": {

0 commit comments

Comments
 (0)