Want to repeat an ng-table and ng rows both from a nested table. How to repeat the table from a nested json. for example json may be :
{
"service_info":{
"service_name":"heading1",
"sl_id":3,
"stack":1
},
"instance_info":[
{
"instance_id":1,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
},
{
"instance_id":2,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
}
]
},
{
"service_info":{
"service_name":"heading2",
"sl_id":3,
"stack":1
},
"instance_info":[
{
"instance_id":1,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
},
{
"instance_id":2,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
}
]
}
need service info as the table heading and instance info as a table row in ng-table. if I use tableparams in it no data is displayed.
After using the trick suggested by #GrumbleSnatch I could get the desired result and here it goes.
$scope.ilist={
"service_info":{
"service_name":"heading1",
"sl_id":3,
"stack":1
},
"instance_info":[
{
"instance_id":1,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
},
{
"instance_id":2,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
}
]
},
{
"service_info":{
"service_name":"heading2",
"sl_id":3,
"stack":1
},
"instance_info":[
{
"instance_id":1,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
},
{
"instance_id":2,
"possible_actions":{
"actions":[
{
"action_name":"modify",
"action_id":2
},
{
"action_name":"deprovision",
"action_id":3
}
]
}
}
]
};
$scope.tabledata=[];
for (var i=0;i< $scope.ilist.length;i++){
$scope.tabledata[i]={};
var datat=$scope.ilist[i];
$scope.tabledata[i].tableParams = new ngTableParams({
page: 1,
count: 10
}, {
total: datat.instance_info.length,
getData: function($defer, params) {
$scope.displayingItems=datat.instance_info.slice((params.page() - 1) * params.count(), params.page() * params.count()).length;
$defer.resolve(datat.instance_info.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
}
and Html goes like this:
<div ng-repeat="instanceList in ilist track by $index">
<h3>{{instanceList.service_info.service_name}}</h3>
<table class="table table-striped table-bordered text-left alignment" class="table" ng-table="tabledata[$index].tableParams" style="margin-top: 20px;">
<tr ng-repeat="instance in $data">
<td data-title="'Instance Name'">
<a style="cursor: pointer; color: #000000; text-decoration: none;">
{{instanceList.service_info.service_name}}_{{instance.instance_id}}
</a>
</td>
</tr>
</table>
</div>
Related
So I have a JSON data file that I am using with Dash/Cytoscope:
"data": {
"label": "Customer",
"properties": {
"score": 8.0,
}
}
I need to compare 'score' with the selector to see if it is bigger than 9.
So far I have tried:
'selector': 'node[properties[score > 9]]'
'selector': '[score > 9]'
'selector': '[properties[score > 9]]'
Unfortunately nothing has worked so far, just invalid syntax.
As canbax pointed out, using functions inside the stylesheet should do the trick.
I added a border-color depending on a nodes score property like this, but you can customize it as you like:
'border-color': function (node) {
if (node.data('properties').score >= 9) { return 'green'}
else { return 'black' }
},
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
boxSelectionEnabled: false,
autounselectify: true,
style: [{
selector: 'node',
css: {
'content': 'data(id)',
'text-valign': 'center',
'text-halign': 'center',
'height': '60px',
'width': '60px',
'border-color': function(node) {
if (node.data('properties').score >= 9) {
return 'green'
} else {
return 'black'
}
},
'border-opacity': '1',
'border-width': '10px'
}
},
{
selector: '$node > node',
css: {
'padding-top': '10px',
'padding-left': '10px',
'padding-bottom': '10px',
'padding-right': '10px',
'text-valign': 'top',
'text-halign': 'center',
'background-color': '#bbb'
}
},
{
selector: 'edge',
css: {
'target-arrow-shape': 'triangle'
}
},
{
selector: ':selected',
css: {
'background-color': 'black',
'line-color': 'black',
'target-arrow-color': 'black',
'source-arrow-color': 'black'
}
}
],
elements: {
nodes: [{
data: {
id: 'n0',
"properties": {
"score": 9.0
}
}
},
{
data: {
id: 'n1',
"properties": {
"score": 10.0
}
}
},
{
data: {
id: 'n2',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n3',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n4',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n5',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n6',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n7',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n8',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n9',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n10',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n11',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n12',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n13',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n14',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n15',
"properties": {
"score": 8.0
}
}
},
{
data: {
id: 'n16',
"properties": {
"score": 8.0
}
}
}
],
edges: [{
data: {
source: 'n0',
target: 'n1'
}
},
{
data: {
source: 'n1',
target: 'n2'
}
},
{
data: {
source: 'n1',
target: 'n3'
}
},
{
data: {
source: 'n2',
target: 'n7'
}
},
{
data: {
source: 'n2',
target: 'n11'
}
},
{
data: {
source: 'n2',
target: 'n16'
}
},
{
data: {
source: 'n3',
target: 'n4'
}
},
{
data: {
source: 'n3',
target: 'n16'
}
},
{
data: {
source: 'n4',
target: 'n5'
}
},
{
data: {
source: 'n4',
target: 'n6'
}
},
{
data: {
source: 'n6',
target: 'n8'
}
},
{
data: {
source: 'n8',
target: 'n9'
}
},
{
data: {
source: 'n8',
target: 'n10'
}
},
{
data: {
source: 'n11',
target: 'n12'
}
},
{
data: {
source: 'n12',
target: 'n13'
}
},
{
data: {
source: 'n13',
target: 'n14'
}
},
{
data: {
source: 'n13',
target: 'n15'
}
},
]
},
layout: {
name: 'dagre',
padding: 5
}
});
body {
font: 14px helvetica neue, helvetica, arial, sans-serif;
}
#cy {
height: 100%;
width: 75%;
position: absolute;
left: 0;
top: 0;
float: left;
}
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.2.17/cytoscape.min.js"></script>
<script src="https://unpkg.com/jquery#3.3.1/dist/jquery.js"></script>
<script src="https://unpkg.com/dagre#0.7.4/dist/dagre.js"></script>
<script src="https://cdn.rawgit.com/cytoscape/cytoscape.js-dagre/1.5.0/cytoscape-dagre.js"></script>
</head>
<body>
<div id="cy"></div>
</body>
</html>
i have a probleme with elastic search when i request it with the following json, i have this error: [bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
i've tried to look on many site but none of them give me a response
{
"query":{
"bool":{
"must":[
{
"match":{
"group_issuer_name":"bnp"
}
},
{
"match":{
"asset_country":"France"
}
}
]
},
"aggs":{
"by_ptf_name":{
"terms":{
"field":"ptf_name.keyword"
},
"aggs":{
"by_ptf_id":{
"terms":{
"field":"ptf_id.keyword"
},
"aggs":{
"sum_of_asset_exposure":{
"sum":{
"field":"asset_exposure"
}
},
"min_of_ptf_total_asset":{
"min":{
"field":"ptf_total_asset"
}
}
}
}
}
}
}
}
}
You are missing }. The query part must be closed and then the aggregation part should start.
The structure should be
{
"query": {},
"aggregation": {}
}
Modify your query as -
{
"query": {
"bool": {
"must": [
{
"match": {
"group_issuer_name": "bnp"
}
},
{
"match": {
"asset_country": "France"
}
}
]
}
}, // note this
"aggs": {
"by_ptf_name": {
"terms": {
"field": "ptf_name.keyword"
},
"aggs": {
"by_ptf_id": {
"terms": {
"field": "ptf_id.keyword"
},
"aggs": {
"sum_of_asset_exposure": {
"sum": {
"field": "asset_exposure"
}
},
"min_of_ptf_total_asset": {
"min": {
"field": "ptf_total_asset"
}
}
}
}
}
}
}
}
I am trying to add config data according to these yang modules:
https://github.com/mbj4668/pyang/blob/master/modules/ietf/ietf-routing.yang
https://github.com/mbj4668/pyang/blob/master/modules/ietf/ietf-ipv4-unicast-routing.yang
I am getting error sysrepocfg error: libyang: Unknown element "next-hop-list" when trying to use "next-hop-list" with below data.
{
"ietf-routing:routing": {
"control-plane-protocols": {
"control-plane-protocol": [
{
"type": "static",
"name": "static-routing-protocol",
"static-routes": {
"ietf-ipv4-unicast-routing:ipv4": {
"route": [
{
"destination-prefix": "0.0.0.0/0",
"next-hop-list": {
"next-hop": [
{
"index": "1",
"next-hop-address": "192.0.2.2"
}
]
}
}
]
}
}
}
]
}
}
}
Unable to figure out the error, any help?
I am able to use "simple-next-hop" with below data, that works fine.
{
"ietf-routing:routing": {
"control-plane-protocols": {
"control-plane-protocol": [
{
"type": "static",
"name": "static-routing-protocol",
"static-routes": {
"ietf-ipv4-unicast-routing:ipv4": {
"route": [
{
"destination-prefix": "0.0.0.0/0",
"next-hop": {
"next-hop-address": "192.0.2.2"
}
}
]
}
}
}
]
}
}
}
Fixed it! 'next-hop-list' had to be inside 'next-hop'.
{
"ietf-routing:routing": {
"control-plane-protocols": {
"control-plane-protocol": [
{
"type": "static",
"name": "static-routing-protocol",
"static-routes": {
"ietf-ipv4-unicast-routing:ipv4": {
"route": [
{
"destination-prefix": "0.0.0.0/0",
"next-hop": {
"next-hop-list": {
"next-hop": [
{
"index": "1",
"next-hop-address": "192.0.2.2"
},
{
"index": "2",
"next-hop-address": "192.0.2.3"
}
]
}
}
}
]
}
}
}
]
}
}
}
My aim is to send 3 separate queries in one ES request using multiple search
I am using NEST client to send query to Elastic search using function below
IElasticClient _elasticClient.LowLevel.Msearch<string>(query).Body;
Passing as a raw query using curl command works absolutely fine, but NEST MSearch only returns "event_results" and "venue_results" but not "location_results"
curl -XPOST localhost:9200/_msearch -d '
{"index" : "search_results"}
{ "size": 0, "query": { "bool": { "must": [ { "term": { "partnersites": "16" } }, { "match_phrase_prefix": { "name": "manchester" } } ] } }, "aggs": { "event_results": { "terms": { "field": "name.keyword", "size": 1 }, "aggs": { "top_tag_hits": { "top_hits": { "size": 1, "_source": [ "name", "groupedName", "groupedDisplayName", "groupedUrl", "eventCode", "venueName", "venueTown", "venueId", "venueUrl", "media", "categories.name" ] } } } } } }
{"index" : "search_results2"}
{ "size": 0, "query": { "bool": { "must": [ { "term": { "partnersites": "16" } }, { "match_phrase_prefix": { "venueName": "Manchester" } } ] } }, "aggs": { "venue_results": { "terms": { "field": "name.keyword", "size": 1 }, "aggs": { "top_tag_hits": { "top_hits": { "size": 1, "_source": [ "name", "groupedName", "groupedDisplayName", "groupedUrl", "eventCode", "venueName", "venueTown", "venueId", "venueUrl", "media", "categories.name" ] } } } } } }
{"index" : "search_results3"}
{ "size": 0, "query": { "bool": { "must": [ { "term": { "partnersites": "16" } }, { "match_phrase_prefix": { "venueTown": "manchester" } } ] } }, "aggs": { "location_results": { "terms": { "field": "name.keyword", "size": 1 }, "aggs": { "top_tag_hits": { "top_hits": { "size": 1, "_source": [ "name", "groupedName", "groupedDisplayName", "groupedUrl", "eventCode", "venueName", "venueTown", "venueId", "venueUrl", "media", "categories.name" ] } } } } } }
'
Is any of you know where the issue could be?
Whenever possible, you don't want to use the "LowLevel" stuff. Instead, use what is available to you on the IElasticClient. Here is an example of how to use IElasticClient.MultiSearch to run 3 searches using the fluent syntax (which is the preferred way to do this).
var mSearchResponse = ElasticClient.MultiSearch(msearch => msearch
.Search<RedemptionES>(
s1 => s1.Query(
q=>q.Term(
t=> t.OnField(f=> f.Id).Value("123")
)
)
)
.Search<RedemptionES>(
s2 => s2.Query(
q => q.Term(
t => t.OnField(f => f.Id).Value("456")
)
)
)
.Search<RedemptionES>(
s3 => s3.Query(
q => q.Term(
t => t.OnField(f => f.Id).Value("789")
)
)
)
);
Issue lies on indention. Try this:
public static string qu = #"{""index"" : ""search_results""}
{ ""size"": 0, ""query"": { ""bool"": { ""must"": [ { ""term"": { ""partnersites"": ""16"" } }, { ""match_phrase_prefix"": { ""name"": ""manchester"" } } ] } }, ""aggs"": { ""event_results"": { ""terms"": { ""field"": ""name.keyword"", ""size"": 1 }, ""aggs"": { ""top_tag_hits"": { ""top_hits"": { ""size"": 1, ""_source"": [ ""name"", ""groupedName"", ""groupedDisplayName"", ""groupedUrl"", ""eventCode"", ""venueName"", ""venueTown"", ""venueId"", ""venueUrl"", ""media"", ""categories.name"" ] } } } } } }
{""index"" : ""search_results2""}
{ ""size"": 0, ""query"": { ""bool"": { ""must"": [ { ""term"": { ""partnersites"": ""16"" } }, { ""match_phrase_prefix"": { ""venueName"": ""Manchester"" } } ] } }, ""aggs"": { ""venue_results"": { ""terms"": { ""field"": ""name.keyword"", ""size"": 1 }, ""aggs"": { ""top_tag_hits"": { ""top_hits"": { ""size"": 1, ""_source"": [ ""name"", ""groupedName"", ""groupedDisplayName"", ""groupedUrl"", ""eventCode"", ""venueName"", ""venueTown"", ""venueId"", ""venueUrl"", ""media"", ""categories.name"" ] } } } } } }
{""index"" : ""search_results3""}
{ ""size"": 0, ""query"": { ""bool"": { ""must"": [ { ""term"": { ""partnersites"": ""16"" } }, { ""match_phrase_prefix"": { ""venueTown"": ""manchester"" } } ] } }, ""aggs"": { ""location_results"": { ""terms"": { ""field"": ""name.keyword"", ""size"": 1 }, ""aggs"": { ""top_tag_hits"": { ""top_hits"": { ""size"": 1, ""_source"": [ ""name"", ""groupedName"", ""groupedDisplayName"", ""groupedUrl"", ""eventCode"", ""venueName"", ""venueTown"", ""venueId"", ""venueUrl"", ""media"", ""categories.name"" ] } } } } } }
";
var result = _elasticClient.LowLevel.Msearch<string>(qu).Body; // Query ES for results.
I have an elasticsearch query:
"query": {
"bool": {
"minimum_should_match": 1,
"should": {
"span_not": {
"exclude": {
"span_or": {
"clauses": [{
"span_near": {
...
},
"span_near": {
...
}
}]
}
}...
I need to have in include clause something like:
"span_or": {
clauses: [
{
"span_near": {...}
}
,
{
"span_and": {
"clases": [
{
"span_near": {...}
}
,
{
"span_near": {...}
}
,
...
]
}
}
]
}
I mean, that i have "or" query:
(span_near or span_near or span_near or ...)
And i want to get "and" query:
(span_near or (span_near and span_near) or ...)
How can i do it? There is no tag "span_and". What tag can i you instead?
Update 1
I have tried this:
"span_or": {
clauses: [
{
"span_multi": {
"match": {
"regexp": {
"message": "путин.*"
}
}
}
}
,
{
"span_multi": {
"match": {
"bool": {
"must": [
{
"term" : { "message" : "test" }
},
{
"term" : { "message" : "rrr" }
}
]
}
}
}
}
]
}
but i have a error:
spanMultiTerm [match] must be of type multi term query
Would normal bool queries solve your problem?
{
"query": {
"bool": {
"must_not": {
"bool": {
"should": [
{
"regexp":{
"message": "путин.*"
}
},
{
"bool": {
"must": [
{
"span_near": {...}
},
{
"span_near": {...}
}
]
}
}
]
}
}
}
}
}
I using the following idea found here:
In certain situations, it can be convenient to have a SpanAndQuery. You can easily simulate this using a SpanNearQuery with a distance of Integer.MAX_VALUE.
"span_or": {
clauses: [
{
"span_multi": {
"match": {
"regexp": {
"message": "путин.*"
}
}
}
}
,
{
"span_near": {
"clauses": [
{
"span_term" : { "message" : "test" }
},
{
"span_term" : { "message" : "rrr" }
}
],
"slop": 2147483647,
"in_order": false
}
}
]
}