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

updated to use without elasticsearch

parent bcdae15b
......@@ -3,6 +3,7 @@
"authors": [
"gsi-upm"
],
"version":"1.0.1",
"description": "This web component displays text field information from elasticsearch",
"main": "tweet-chart.html",
"keywords": [
......
......@@ -32,6 +32,7 @@ paper-icon-button.green:hover {
margin: 10px;
padding: 10px;
border-radius: 5px;
}
.positive {
......
......@@ -19,7 +19,7 @@
<span>{{title}}</span>
</div>
<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>
<span class="text">{{tweet.text}}</span></br>
<span style="font-weight: bold">{{tweet.name}}</span></br>
......@@ -78,6 +78,11 @@
value: function() { return []; }
},
datos:{
type: Object,
observer: '_dataChanged'
},
field: {
type: String
},
......@@ -98,105 +103,18 @@
}
},
observers: [
'_filtersChange(filters.*)'
],
ready: function() {
this.field ? this.queryDefault() : undefined
},
queryDefault: function() {
var client = new $.es.Client({
hosts: this.host
});
_dataChanged: function() {
var that = this
client.search({
// undocumented params are appended to the query string
index: this.index,
type: this.subindex,
body: {
size: 10,
query: {
match_all: {}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
var results = []
hits.forEach(function(entry) {
var hits = this.datos.hits.hits;
var results = []
hits.forEach(function(entry) {
results.push(entry._source);
});
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
});
}
that.data = results
},
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