Commit 0f7a54d3 authored by Daniel Suarez Souto's avatar Daniel Suarez Souto
Browse files

nested agg for entity name and type

parent afef3ef6
......@@ -13,6 +13,7 @@
<link rel="import" href="/bower_components/paper-menu/paper-menu.html">
<link rel="import" href="/bower_components/paper-autocomplete/paper-autocomplete.html">
<link rel="import" href="/elements/entities-chart/entities-chart.html">
<link rel="import" href="/elements/categories-chart/categories-chart.html">
<link rel="import" href="/elements/people-chart/people-chart.html">
<link rel="import" href="/elements/news-chart/news-chart.html">
<link rel="import" href="/elements/propaganda-chart/propaganda-chart.html">
......@@ -65,75 +66,8 @@
<div class="row">
<material-search active="true" search-value="{{query}}" style="margin: 0 15px;"></material-search>
<br>
</div>
<br>
<!-- <div class="row">
<div class="col-md-4">
<number-chart
icon="/images/news.ico"
stylebg="bg-white"
title="Selected elements"
data="{{data}}">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/CNN"
aggKey="schema:author"
title="CNN"
icon="/images/cnn_blanco.svg"
stylebg="bg-red">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/The_New_York_Times"
aggKey="schema:author"
title="The New York Times"
icon="/images/times1.png"
stylebg="bg-green">
</number-chart>
</div>
</div>
<div class="row">
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/Al_Jazeera"
aggKey="schema:author"
title="Al Jazeera"
icon="/images/Aljazeera_blanco.svg"
subtitle="Total"
stylebg="bg-yellow">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/Twitter"
aggKey="schema:author"
title="Twitter"
icon="/images/twitter.svg"
subtitle="Total"
stylebg="bg-aqua">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
aggKey="type"
object="schema:Article"
title="Magazines"
icon="/images/magazine.svg"
subtitle="Total"
stylebg="bg-purple">
</number-chart>
</div>
</div> -->
<div class="row">
<div class="col-md-6">
<number-chart
......@@ -175,37 +109,6 @@
</div>
</div>
<br>
<!-- <div class="row">
<div class="col-md-6">
<google-chart
field="schema:author"
data="{{data}}"
sources="{{sources}}"
id='pie-chart3'
extra-id='pie-chart3'
type='pie'
filters="{{filters}}"
icon='icons:reorder'
options='{"title": "Source"}'
cols='[{"label": "type", "type": "string"},{"label": "Count", "type": "number"}]'>
</google-chart>
</div>
<div class="col-md-6">
<google-chart
field="sentiment"
data="{{data}}"
id='barsentiment'
extra-id='1'
type='column'
filters="{{filters}}"
icon='social:mood'
options='{"title": "Sentiments"}'
cols='[{"label": "Sentiment", "type": "string"},{"label": "Count", "type": "number"}]'>
</google-chart>
</div>
</div>
<br> -->
<div class="row">
<div class="col-md-6">
<entities-chart
......@@ -219,25 +122,19 @@
</entities-chart>
</div>
<div class="col-md-6">
<people-chart
<categories-chart
field="categories.name"
data="{{data}}"
title="People"
icon="maps:person-pin"
title="Categories"
icon="icons:list"
param="{{param}}"
id="entitieschart"
id="categorieschart"
filters="{{filters}}">
</people-chart>
</categories-chart>
</div>
</div>
<categories-chart
field="categories.name"
data="{{data}}"
title="Categories"
icon="icons:list"
param="{{param}}"
id="categorieschart"
filters="{{filters}}">
</categories-chart>
<br>
<div class="row">
<div class="col-md-6">
......@@ -255,6 +152,20 @@
</google-chart>
</div>
<div class="col-md-6">
<people-chart
data="{{data}}"
title="People"
icon="maps:person-pin"
param="{{param}}"
id="entitieschart"
filters="{{filters}}">
</people-chart>
</div>
</div>
<br>
<div class="row">
<div class="col-md-12">
<google-chart
field="schema:datePublished"
data="{{data}}"
......@@ -328,6 +239,7 @@
</happymap-element>
</div>
</div>
</div>
<div>
<yasgui-ui
......@@ -504,6 +416,9 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
}/*,
match: this.search*/
},
sort: {
"schema:datePublished":"desc"
},
aggs: {
type: {
terms: {
......@@ -521,28 +436,29 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
}
}
},
'entities.type': {
terms: {
field: "entities.@type.keyword",
order: {
_count: "desc"
}
}
},
'entities.name': {
terms: {
field: "entities.schema:name.keyword",
size : 16,
order: {
_count: "desc"
}
}
terms: {
field: "entities.schema:name.keyword",
size : 16,
order: {
_count: "desc"
}
},
aggs: {
'entity_type': {
"top_hits": {
"_source": {
"includes": [ "entities.@type","entities.schema:name"]
},
"size" : 1
}
}
}
},
'categories.name': {
terms: {
field: "taxonomies.rdfs:label.keyword",
size:8,
size:10,
order: {
_count:"desc"
}
......@@ -581,7 +497,9 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
that.ids = myids;
that.data = resp;
//console.log(that.data);
});
}
}
......
......@@ -66,75 +66,8 @@
<div class="row">
<material-search active="true" search-value="{{query}}" style="margin: 0 15px;"></material-search>
<br>
</div>
<br>
<!-- <div class="row">
<div class="col-md-4">
<number-chart
icon="/images/news.ico"
stylebg="bg-white"
title="Selected elements"
data="{{data}}">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/CNN"
aggKey="schema:author"
title="CNN"
icon="/images/cnn_blanco.svg"
stylebg="bg-red">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/The_New_York_Times"
aggKey="schema:author"
title="The New York Times"
icon="/images/times1.png"
stylebg="bg-green">
</number-chart>
</div>
</div>
<div class="row">
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/Al_Jazeera"
aggKey="schema:author"
title="Al Jazeera"
icon="/images/Aljazeera_blanco.svg"
subtitle="Total"
stylebg="bg-yellow">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
object="http://dbpedia.org/resource/Twitter"
aggKey="schema:author"
title="Twitter"
icon="/images/twitter.svg"
subtitle="Total"
stylebg="bg-aqua">
</number-chart>
</div>
<div class="col-md-4">
<number-chart
data="{{data}}"
aggKey="type"
object="schema:Article"
title="Magazines"
icon="/images/magazine.svg"
subtitle="Total"
stylebg="bg-purple">
</number-chart>
</div>
</div> -->
<div class="row">
<div class="col-md-6">
<number-chart
......@@ -176,37 +109,6 @@
</div>
</div>
<br>
<!-- <div class="row">
<div class="col-md-6">
<google-chart
field="schema:author"
data="{{data}}"
sources="{{sources}}"
id='pie-chart3'
extra-id='pie-chart3'
type='pie'
filters="{{filters}}"
icon='icons:reorder'
options='{"title": "Source"}'
cols='[{"label": "type", "type": "string"},{"label": "Count", "type": "number"}]'>
</google-chart>
</div>
<div class="col-md-6">
<google-chart
field="sentiment"
data="{{data}}"
id='barsentiment'
extra-id='1'
type='column'
filters="{{filters}}"
icon='social:mood'
options='{"title": "Sentiments"}'
cols='[{"label": "Sentiment", "type": "string"},{"label": "Count", "type": "number"}]'>
</google-chart>
</div>
</div>
<br> -->
<div class="row">
<div class="col-md-6">
<entities-chart
......@@ -514,6 +416,9 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
}/*,
match: this.search*/
},
sort: {
"schema:datePublished":"desc"
},
aggs: {
type: {
terms: {
......@@ -531,28 +436,29 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
}
}
},
'entities.type': {
terms: {
field: "entities.@type.keyword",
order: {
_count: "desc"
}
}
},
'entities.name': {
terms: {
field: "entities.schema:name.keyword",
size : 16,
order: {
_count: "desc"
}
}
terms: {
field: "entities.schema:name.keyword",
size : 16,
order: {
_count: "desc"
}
},
aggs: {
'entity_type': {
"top_hits": {
"_source": {
"includes": [ "entities.@type","entities.schema:name"]
},
"size" : 1
}
}
}
},
'categories.name': {
terms: {
field: "taxonomies.rdfs:label.keyword",
size:8,
size:10,
order: {
_count:"desc"
}
......@@ -589,18 +495,7 @@ H2020 RIA Action Grant No. 740934 under the call SEC-06-FCT-2016 — Developing
var myids = []
resp.hits.hits.forEach(function(entry){myids.push(entry._id)})
that.ids = myids;
//console.log(that.sources)
/*var sources=that.sources
for (var i=0; i<resp['aggregations']['schema:author']['buckets'].length;i++) {
var key=resp['aggregations']['schema:author']['buckets'][i]["key"]
console.log(key)
if(key in sources)
console.log(sources)
resp['aggregations']['schema:author']['buckets'][i]["key"]=sources[key]
}*/
//resp['aggregations']['schema:author']['buckets'][1]["key"]="Dabiq"
//resp['aggregations']['schema:author']['buckets'][2]["key"]="Rumiyah"
that.data = resp;
//console.log(that.data);
......
......@@ -48,7 +48,6 @@
display: inline-block;
margin: 0 0 7px 20px;
position: relative;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 0.9em;
font-weight: bold;
text-decoration: none;
......@@ -142,8 +141,8 @@
<div id="nodata" style="margin-top: 35px">No entries match the current filters</div>
<div id="tagwrapper" style="min-height: 215px;">
<br>
<template is="dom-repeat" items="{{categories}}" as="category">
<paper-button class="tag active" data$="{{category.0}}" on-tap="filter"><span>{{getCategory(category.0)}}</span><span class="number">{{category.1}}</span></paper-button>
<template is="dom-repeat" items="{{categories}}" as="category" >
<paper-button class="tag active" data$="{{category.0}}" on-tap="filter" title$="{{getTitle(category.0)}}"><span>{{getCategory(category.0)}}</span><span class="number">{{category.1}}</span></paper-button>
</template>
</div>
<div style="float: right; bottom: 10px; width: 100%; display: flex; flex-direction: row; justify-content: flex-end; align-content: center;">
......@@ -246,7 +245,16 @@
},
getCategory: function(category){
arr_category=category.split("/")
return arr_category[arr_category.length -1]
name=arr_category[arr_category.length -1]
if(name.length<50){
return name
}
return name.substring(0,50)+"..."
},
getTitle: function(category){
arr_category=category.split("/")
name=arr_category[arr_category.length -1]
return name
},
removeFilters: function(){
this.filters = [];
......
......@@ -48,7 +48,6 @@
display: inline-block;
margin: 0 0 7px 20px;
position: relative;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 0.9em;
font-weight: bold;
text-decoration: none;
......@@ -232,7 +231,12 @@
//console.log(hits)
var data = [];
hits.forEach(function(entry) {
data.push([entry.key, entry.doc_count]);
entry.entity_type.hits.hits[0]._source.entities.forEach(function(entity){
if(entry.key===entity['schema:name']){
//console.log([entry.key, entry.doc_count,entity['@type'][0]])
data.push([entry.key, entry.doc_count,entity['@type'][0]]);
}
});
});
if(data.length == 0 ){
this.$.tagwrapper.style.visibility = 'hidden';
......
......@@ -324,8 +324,8 @@
},
getCategory: function(category){
var arr=category["rdfs:label"].split("/")
//console.log(arr[arr.length-1])
return arr[arr.length-1]
//console.log(arr[arr.length-1])
return arr[arr.length-1]
},
highlightEntity: function(e) {
......
......@@ -26,7 +26,7 @@
<app-location route="{{route}}"></app-location>
<elastic-client
config='{"host": "http://localhost:19200"}'
config='{"host": "http://sefarad-elasticsearch.cluster.gsi.dit.upm.es"}'
client="{{client}}"
cluster-status="{{myStatus}}">
</elastic-client>
......
Supports Markdown
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