{{tweet.text}}
{{tweet.name}}
@@ -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) {