I am Taka.
I tried to get the highlighted results on Watson Discovery in Node.red.
It doesn't work.
Could you tell me if we can get the highlighted results in Node.red
and how to do it if we can?
Here is that I tried.
I created a function node in Node.red to pass query
from Discovery query builder to Discovery node as follows.
msg.discoveryparams = {};
msg.discoveryparams.environment_id = 'xxxxxxxxxxxxx';
msg.discoveryparams.collection_id = 'xxxxxxxxxxxxxxxx';
msg.discoveryparams.nlp_query = true;
msg.discoveryparams.query = msg.payload;<--query from query builder
msg.discoveryparams.query_options = {highlight:true}; <-- add to get highlighted
return msg;
Thanks.
query_options has not been implemented in the Node-RED node for Discovery. If you would like it to be be implemented them please raise an issue against the github repo - https://github.com/watson-developer-cloud/node-red-node-watson
here is a spippet of code
var discovery = new watson.DiscoveryV1(params.discovery);
discovery.query(
{environment_id: params.discovery.environment_id,
collection_id: params.discovery.collection_id,
natural_language_query: req.body.input.text,
passages: true,
highlight: true // this will enable highlight
}
Related
Note: the code here is Go but happy to see answers in any CDK language.
In AWS CDK, you can create Launch Configurations:
// Create the launch configuration
lc := awsautoscaling.NewCfnLaunchConfiguration(
stack,
jsii.String("asg-lc"),
&awsautoscaling.CfnLaunchConfigurationProps{
...
},
)
But there is no obvious parameter or function in the Auto-Scaling Group props to attach it.
I have set the update policy:
UpdatePolicy: awsautoscaling.UpdatePolicy_RollingUpdate,
What I want to do is be able to call an auto-refresh in the CI system when an AMI configuration has changed:
aws autoscaling start-instance-refresh --cli-input-json file://asg-refresh.json
The problem is that the launch configuration appears to have been created automatically when the stack is first created and doesn't change on update and has incorrect values (AMI ID is outdated).
Is there a way to define/refresh the launch config using CDK to update the AMI ID? It's a simple change in the UI.
If you use the L2 AutoScalingGroup Construct, you can run cdk deploy after updating the AMI and it should launch a new one for you. Also with this Construct, the Launch Configuration is created for you. You don't really need to worry about it.
IMachineImage image = MachineImage.Lookup(new LookupMachineImageProps()
{
Name = "MY-AMI", // this can be updated on subsequent deploys
});
AutoScalingGroup asg = new AutoScalingGroup(this, $"MY-ASG", new AutoScalingGroupProps()
{
AllowAllOutbound = false,
AssociatePublicIpAddress = false,
AutoScalingGroupName = $"MY-ASG",
Vpc = network.Vpc,
VpcSubnets = new SubnetSelection() { Subnets = network.Vpc.PrivateSubnets },
MinCapacity = 1,
MaxCapacity = 2,
MachineImage = image,
InstanceType = new InstanceType("m5.xlarge"),
SecurityGroup = sg,
UpdatePolicy = UpdatePolicy.RollingUpdate(new RollingUpdateOptions()
{
}),
});
I've set up AmazonAutoScalingAsync client as well as many others but I'm unable to retrieve the existing ASGs.
BasicSessionCredentials sessionCredentials =
new BasicSessionCredentials(
credentials.getAccessKeyId(),
credentials.getSecretAccessKey(),
credentials.getSessionToken());
// Assume role
AWSSecurityTokenService sts_client_mfa =
AWSSecurityTokenServiceClientBuilder.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(sessionCredentials))
.build();
AssumeRoleRequest request =
new AssumeRoleRequest()
.withRoleSessionName("proserv-" + username)
.withRoleArn("myarn");
AssumeRoleResult response = sts_client_mfa.assumeRole(request);
Then I build the auto-scaling client as follows:
autoScalingClient =
AmazonAutoScalingAsyncClientBuilder.standard()
.withCredentials(
new AWSStaticCredentialsProvider(
new BasicSessionCredentials(
response.getCredentials().getAccessKeyId(),
response.getCredentials().getSecretAccessKey(),
response.getCredentials().getSessionToken())))
.withRegion(region)
.build();
These are the same steps I do from the AWS console but can't see the same results on the Java code.
getAutoScalingClient()
.describeAutoScalingGroupsAsync()
.get()
.getAutoScalingGroups()
.forEach(
group -> {
System.out.println(group);
});
getAutoScalingClient()
.describeAutoScalingInstancesAsync()
.get()
.getAutoScalingInstances()
.forEach(
entry -> {
System.out.println(entry);
});
Any thoughts?
Just figured it out. I was using the wrong region. After switching to the correct region it displayed as expected.
feathers-client 2.3.0
syncfusion-javascript 15.3.29
I have been trying for awhile to create a syncfusion custom adapter for the feathers socket.io version of it's client. I know I can use rest to get data but in order for me to do offline sync I need to use the feathers-offline-realtime plugin.
Also I am using this in an aurelia project so I am using es6 imports with babel.
Here is a code snippet I have tried, I can post the whole thing if needed.
I am also not sure if just using the Adapter vs UrlAdapter is correct as I need sorting and paging to hit the server and not just to do it locally. I think I can figure that part out if I can at least get some data back.
Note: Per Prince Oliver I am adding a clarification to the question I need to be able to call any methods of the adapter as well besides just proccessQuery such as onSort. When the datagrid calls the onSort method I need to be able to call my api using the feathers socket.io client since it handles socket.io in a special manner for offline capabilities.
import io from 'socket.io-client';
import * as feathers from 'feathers-client';
const baseUrl = 'http://localhost:3030';
const socket = io.connect(baseUrl);
const client = feathers.default()
.configure(feathers.hooks())
.configure(feathers.socketio(socket));
const customers = client.service('customers');
export class FeathersAdapter {
feathersAdapter = new ej.Adaptor().extend({
processQuery: function (ds, query) {
let results
makeMeLookSync(function* () {
results = yield customers.find();
console.log(results);
});
The result is undefined. I have tried several other ways but this one seems like it should work.
REVISED CODE:
I am now getting data but also strange error as noted in the picture when I call
let results = await customers.find();
The process then continues and I get data but when the result variable is returned there is still no data in the grid.
async processQuery(ds, query) {
let baseUrl = 'http://localhost:3030';
let socket = io.connect(baseUrl);
let client = feathers.default()
.configure(feathers.hooks())
.configure(feathers.socketio(socket));
let customers = client.service('customers');
let results = await customers.find();
var result = results, count = result.length, cntFlg = true, ret, key, agg = {};
for (var i = 0; i < query.queries.length; i++) {
key = query.queries[i];
ret = this[key.fn].call(this, result, key.e, query);
if (key.fn == "onAggregates")
agg[key.e.field + " - " + key.e.type] = ret;
else
result = ret !== undefined ? ret : result;
if (key.fn === "onPage" || key.fn === "onSkip" || key.fn === "onTake" || key.fn === "onRange") cntFlg = false;
if (cntFlg) count = result.length;
}
return result;
The processQuery method in the DataManager is used to process the parameter which are set in the ej.Query like skip, take, page before fetching the data. Then the data is fetched asynchronously based on these parameters and fetched data is processed in processResponse method to perform operations like filtering or modifying. The processQuery function operates synchronously and it does not wait for the asynchronous process to complete. Hence the returned data from the API did not get bound on the Grid and throws undefined error.
So, if you are using the socket.io to fetch the data from the API, then the data can be directly bound to the Grid control using the dataSource property. Once the dataSource is updated with the result, it will be reflected in Grid automatically through two-way binding.
[HTML]
<template>
<div>
<ej-grid e-data-source.bind="gridData" e-columns.bind="cols"> </ej-grid>
</div>
</template>
[JS]
let baseUrl = 'http://localhost:3030';
let socket = io.connect(baseUrl);
let client = feathers.default()
.configure(feathers.hooks())
.configure(feathers.socketio(socket));
let customers = client.service('customers');
let results = await customers.find();
this.gridData = results; // bind the data to Grid
Trying to load OSM on windows Form using C# and GMap.Net I am getting this error
Exception:The remote server returned an error: (403) Forbidden
private void Form1_Load(object sender, EventArgs e)
{
gMapControl1.DragButton = MouseButtons.Left;
gMapControl1.CanDragMap = true;
gMapControl1.MapProvider = GMapProviders.OpenStreetMap;
gMapControl1.Position = new GMap.NET.PointLatLng(54.6961334816182, 25.2985095977783);
gMapControl1.MinZoom = 0;
gMapControl1.MaxZoom = 24;
gMapControl1.Zoom = 9;
gMapControl1.AutoScroll = true;
}
Can you please let me know why this is happening and how I can fix it?
don't forget to set the instance mode to server/cache and set it to the instance of the open street map provider instead of 'GMapProviders.OpenStreetMap'
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
gMapControl1.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;
It could also be your web proxy settings, see
https://stackoverflow.com/a/19609539/2368681
"Hi,
All libraries that send a fake user-agent and other faked headers to make the requests appear as if they are coming from web browsers are being blocked. Fix the headers and set a real User-Agent to identify your app and the requests will work again.
Please review our usage policy:
https://operations.osmfoundation.org/policies/tiles/ "
This is verbatim reply from OSM.
https://github.com/judero01col/GMap.NET/pull/45 is being used to track this issue. And hopefully a fix will be merged in a a day or two.
I changed Map Provider from "OpenStreetMapProvider" to "GoogleMapProvider" and the error disappeared.
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
mapView.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
I use rt:activeUsers metric to get active users on website for realtime data.
I want to get active users in real time for a specific page (path or url), not the whole website. Is there a way to implement it? I went through API Explorer but gain no success.
For anybody else looking for this below is an example of how I accomplished this in javascript.
I started with the sample at: https://ga-dev-tools.appspot.com/embed-api/third-party-visualizations/
That sample uses a extension to the embed api to get active users: active-users.js
I didn't know where to get that active-users.js file so I just used the developer tools in Chrome and grabbed it that way. Saved it locally and linked to it in my page. If anyone knows a official location to get that please comment below. Thx.
If you look at the source to that file, I modifed the pollActiveUsers function to add a filters parameter like so:
pollActiveUsers_: function () {
var t = this.get(),
i = 1e3 * (t.pollingInterval || 5);
if (isNaN(i) || i < 5e3)
throw new Error("Frequency must be 5 seconds or more.");
this.polling_ = !0,
gapi.client.analytics.data.realtime.get({
ids: t.ids,
metrics: "rt:activeUsers",
filters: t.filters
}).then(function (t) {
var e = t.result,
s = e.totalResults ? +e.rows[0][0] : 0,
n = this.activeUsers;
this.emit("success", {
activeUsers: this.activeUsers
}),
s != n && (this.activeUsers = s, this.onChange_(s - n)),
1 == this.polling_ && (this.timeout_ = setTimeout(this.pollActiveUsers_.bind(this), i))
}
.bind(this))
},
Now in my page javascript I can call it like so:
var activeUsers = new gapi.analytics.ext.ActiveUsers({
container: 'active-users-container',
pollingInterval: 5,
filters: "rt:pagePath==/somepath/somepage/",
ids: "ga:<yourviewid>"
});
Hope that helps somebody.
While the Real-time API is very limited it does allow you to use filters. Filters are a kind of where clause.
The real-time documentation is also very limited but you can look at the documentation for filters on the core reporting API it works the same
filters=ga:browser%3D~%5EFirefox
I think you should check out the dimension rt:pagePath its probably what you are looking for.