Commit 9564ae46 authored by Alberto Pascual's avatar Alberto Pascual

updated to use without elasticsearch

parent bcdae15b
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"authors": [ "authors": [
"gsi-upm" "gsi-upm"
], ],
"version":"1.0.1",
"description": "This web component displays text field information from elasticsearch", "description": "This web component displays text field information from elasticsearch",
"main": "tweet-chart.html", "main": "tweet-chart.html",
"keywords": [ "keywords": [
......
...@@ -32,6 +32,7 @@ paper-icon-button.green:hover { ...@@ -32,6 +32,7 @@ paper-icon-button.green:hover {
margin: 10px; margin: 10px;
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 5px;
} }
.positive { .positive {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<span>{{title}}</span> <span>{{title}}</span>
</div> </div>
<template is="dom-repeat" items="{{data}}" as="tweet"> <template is="dom-repeat" items="{{data}}" as="tweet">
<div class$="{{checkSentiment(tweet.sentiment)}}"> <div class$="{{checkSentiment(tweet.sentiment)}} same-height">
<img src={{checkSource(tweet.name)}} style="width: 60px"></br> <img src={{checkSource(tweet.name)}} style="width: 60px"></br>
<span class="text">{{tweet.text}}</span></br> <span class="text">{{tweet.text}}</span></br>
<span style="font-weight: bold">{{tweet.name}}</span></br> <span style="font-weight: bold">{{tweet.name}}</span></br>
...@@ -78,6 +78,11 @@ ...@@ -78,6 +78,11 @@
value: function() { return []; } value: function() { return []; }
}, },
datos:{
type: Object,
observer: '_dataChanged'
},
field: { field: {
type: String type: String
}, },
...@@ -98,105 +103,18 @@ ...@@ -98,105 +103,18 @@
} }
}, },
observers: [
'_filtersChange(filters.*)'
],
ready: function() { ready: function() {
this.field ? this.queryDefault() : undefined
}, },
queryDefault: function() { _dataChanged: function() {
var client = new $.es.Client({
hosts: this.host
});
var that = this var that = this
client.search({ var hits = this.datos.hits.hits;
// undocumented params are appended to the query string var results = []
index: this.index, hits.forEach(function(entry) {
type: this.subindex,
body: {
size: 10,
query: {
match_all: {}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
var results = []
hits.forEach(function(entry) {
results.push(entry._source); results.push(entry._source);
});
that.data = results
}); });
}, that.data = results
queryChange: function(value) {
var client = new $.es.Client({
hosts: this.host
});
var that = this
client.search({
// undocumented params are appended to the query string
index: this.index,
type: this.subindex,
body: {
size: 10,
query: {
multi_match:{
query: this.query,
fields: this.fields
}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
var results = []
hits.forEach(function(entry) {
results.push(entry._source);
});
that.data = results
});
},
/** Fired when a search is made.
*
* @event query-change
* @param {Object} detail
* @param {Object} detail.query The search string.
*/
_queryChanged: function() {
this.query ? this.queryChange(this.query) : this.queryDefault();
},
_filtersChange: function() {
if(filtered){
var client = new $.es.Client({
hosts: this.host
});
var that = this
client.search({
// undocumented params are appended to the query string
index: this.index,
type: this.subindex,
body: {
size: 10,
query: {
bool: {
must: this.filters,
}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
var results = []
hits.forEach(function(entry) {
results.push(entry._source);
});
that.data = results
});
}
}, },
checkSentiment: function(sentiment) { checkSentiment: function(sentiment) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment