Want to get the data from a nested mongodb from R shiny app - r

My mongodb is looking like this :
"_id" : ObjectId("5751749723be8328848af30e"),
"mem_id" : 1.0,
"mem_name" : "Member1",
"home" : "8001234567",
"mobile" : "8771231234",
"email" : "jd#example.com",
"mem_create_date" : ISODate("2016-06-03T12:14:15.642Z"),
"paymethod" : {
"pm_id" : "99991",
"pm_name" : "FA11",
"pm_create_Date" : ISODate("2013-12-09T21:05:00.000Z"),
"routing_no" : "075000051"
},
"payee" : {
"pae_id" : "88881",
"pae_name" : "Payee1",
"home" : "800-123-45671",
"mobile" : "877-123-12341",
"email" : "jd#example.com",
"act_no" : "0213654781",
"pae_create_date" : ISODate("2013-12-09T21:05:00.000Z"),
"payment" : {
"pmt_id" : "66661",
"pmt_amt" : "71",
"pmt_create_date" : ISODate("2013-12-09T21:05:00.000Z"),
"pmt_type" : "check"
}
}
}
I need to get these values with the help of mongolite and show them in a plot/graph with R shiny web app.
I could not find any example with nested mongodb on net. And whenever i am trying to read the data i am getting the below err :
error in if (inherits(x j dataframe ) && ncol(xj) 1l) x j - as.matrix(x j )
Can anyone please help/guide me here. I am a java developer but i am new to R language.
Thanks.

Related

Kibana and OpenSearch incompatible versions

I'm trying to integrate Kibana with my OpenSearch ( is it possible ? ). Unfortunately I get a version error.
Is there any way to use opensearch in kibana?
These are the versions I get via curl:
curl -k -u "admin:PASSWORD" "https://IP:9200/"
{
"name" : "node-1",
"cluster_name" : "cluster",
"cluster_uuid" : "he6gqhl2S-6dlVv6dyPOEA",
"version" : {
"number" : "7.10.2",
"build_type" : "rpm",
"build_hash" : "e505b10357c03ae8d26d675172402f2f2144ef0f",
"build_date" : "2022-01-14T03:38:06.881862Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "The OpenSearch Project: https://opensearch.org/"
}
They are very tightly coupled and aren't really supposed to work together, so I doubt they will (or it would be very brittle).
If you want to have Kibana, why not Elasticsearch under the hood?

Using jq to loop over objects and return an iterated value

I have an enteresting TODO that I'd like some eyes on. I'm using journalctl to grab system journal entries and output as JSON. journalctl outputs as JSON objects separated by a newline.
Here's a sample of a JSON object outputted from journalctl:
{ "__CURSOR" : "s=bd3afe956aec45d89cf3939e839c3647;i=3e084;b=6dd8a3060bdb448d848f4694339c6e94;m=5d0fd53a6;t=5c797ae76d38f;x=6cdb742ba83df8f5", "__REALTIME_TIMES
TAMP" : "1626829164613612", "__MONOTONIC_TIMESTAMP" : "24980054950", "_BOOT_ID" : "6dd8a3030bdb446d858f4694337c6e94", "PRIORITY" : "6", "SYSLOG_FACILITY" : "3",
"CODE_FILE" : "../src/core/job.c", "CODE_LINE" : "845", "CODE_FUNC" :
"job_log_status_message", "SYSLOG_IDENTIFIER" : "systemd", "JOB_TYPE" : "start", "JOB_RES
ULT" : "done", "MESSAGE_ID" : "39f53479d3a045ac8e11786248231fbf", "_TRANSPORT" : "journal", "_PID" : "11282", "_UID" : "1162", "_GID" : "1162", "_COMM" : "syste
md", "_EXE" : "/lib/systemd/systemd", "_CMDLINE" : "/lib/systemd/systemd --user", "_CAP_EFFECTIVE" : "0", "_SELINUX_CONTEXT" : "unconfined\n", "_AUDIT_SESSION"
: "974", "_AUDIT_LOGINUID" : "1162", "_SYSTEMD_CGROUP" : "/user.slice/user-1162.slice/user#1162.service/init.scope", "_SYSTEMD_OWNER_UID" : "1162", "_SYSTEMD_UN
IT" : "user#1162.service", "_SYSTEMD_USER_UNIT" : "init.scope", "_SYSTEMD_SLICE" : "user-1162.slice", "_SYSTEMD_USER_SLICE" : "-.slice", "_SYSTEMD_INVOCATION_ID
" : "1f72568e79c34f14a525f98ce6a151c2", "_MACHINE_ID" : "32c9faf3dd90422881ce03690ebf0015", "_HOSTNAME" : "ip-192-168-22-27", "MESSAGE" : "Listening on port.", "USER_UNIT" : "dirmngr.socket", "USER_INVOCATION_ID" :
"7c1e914aada947cd80a45d68275751dc", "_SOURCE_REALTIME_TIMESTAMP" :
"1626829165607533" }
I'm using --after-cursor to get a subset of the journal. There is no --before-cursor option afaik so I'm trying to find a way to stop at a specific cursor and search the JSON objects between the first and last cursor.
At the moment I'm using the following snippet (sloppy by my own admission) to search the journal after a cursor and count the objects where a match is found.
journalctl -u my-service --after-cursor="$FIRST_CURSOR" -o json | jq -n 'inputs|select(.MESSAGE|test(".*My search string .*")) | jq length | wc -l
I'd like to do this more intelligently with possibly an if/else statement but I'm a jq novice.
A jq-only solution would be:
[inputs|select(.MESSAGE|test("My search string")) | length] | length
Notice there is no need for the initial or final .* in the regex
For future reference, please follow the "mcve" guidelines at http://stackoverflow.com/help/mcve .
In particular, your JSON got mangled while copying-and-pasting into SO; and an actual example, with expected output, would be appreciated.

How to query a Document by ObjectId with rmongodb

Here is what you get in mongo shell :
db.col.find(ObjectId("5571849db1969e0a6eb32731")).pretty()
{
"_id" : ObjectId("5571849db1969e0a6eb32731"),
"name" : "Some name",
"logo" : "Some logo",
"users" : [
ObjectId("5571830031c7fc341bc2e105"),
ObjectId("5571830031c7fc341bc2e107")
],
"admins" : [ ],
"__v" : 0,
"steps" : 5782
}
Here is what I get in rmongo :
myResult <- mongo.find(Connexion, "db.col", query='ObjectId("5571849db1969e0a6eb32731")')
#Error in mongo.bson.from.JSON(arg) :
# Not a valid JSON content: ObjectId("5571849db1969e0a6eb32731")
So, how to do it right ?
Just in case : I had a look at this already. But mongolite doesn't support authentication (which is therefore a no-go) and I don't understand what to do with the second answer. If I try
result <- mongo.find(Connexion, "db.col", query=mongo.oid.from.string("5571849db1969e0a6eb32731"))
I get
# Error in mongo.bson.from.argument(query) : Can't convert to bson: argument should be one of 'list', 'mongo.bson' or 'character'(valid JSON)
This should work:
result <- mongo.find(Connexion, "db.col", query=list('_id' = mongo.oid.from.string("5571849db1969e0a6eb32731")))

Uncaught TypeError: Object [object Object] has no method 'fancybox' in wordpress

Im using wordpress and i install a plugin called form-lightbox but i have a error in console of chrome:
Uncaught TypeError: Object [object Object] has no method 'fancybox'
in this code:
<script type="text/javascript">
var iFrame_1369701509296 = jQuery("#form-lightbox-1369701509296 iframe").attr("src");
jQuery(document).ready(function() {jQuery(".fl_box-1369701509296").fancybox({
Uncaught TypeError: Object [object Object] has no method 'fancybox'
"type" :"inline",
"href" :"#form-lightbox-1369701509296",
"padding" : 10,"margin" : 20,"opacity" : true,"modal" : false,"scrolling" : "","autoScale" : true,"autoDimensions" : true,"width" : 560,"height" : 340,"centerOnScroll" : false,"hideOnOverlayClick" : true,"hideOnContentClick" : false,"overlayShow" : true,"overlayOpacity" : 0.30,"overlayColor" : "#666","titleShow" : true,"titlePosition" : "outside","transitionIn, transitionOut" : "elastic","speedIn" : 300,"changeSpeed" : 300,"changeFade" : "fast","easingIn, easingOut" : "elastic","showCloseButton" : true,"enableEscapeButton" : true,
"onClosed" : function(){ jQuery("#form-lightbox-1369701509296 iframe").attr("src", iFrame_1369701509296); }
});
setTimeout(function(){
jQuery.fancybox(
jQuery("#form-lightbox-1369701509296").html(), {
"padding" : 10,"margin" : 20,"opacity" : true,"modal" : false,"scrolling" : "","autoScale" : true,"autoDimensions" : true,"width" : 560,"height" : 340,"centerOnScroll" : false,"hideOnOverlayClick" : true,"hideOnContentClick" : false,"overlayShow" : true,"overlayOpacity" : 0.30,"overlayColor" : "#666","titleShow" : true,"titlePosition" : "outside","transitionIn, transitionOut" : "elastic","speedIn" : 300,"changeSpeed" : 300,"changeFade" : "fast","easingIn, easingOut" : "elastic","showCloseButton" : true,"enableEscapeButton" : true,
"onClosed" : function(){ jQuery("#form-lightbox-1369701509296 iframe").attr("src", iFrame_1369701509296); }
}
)
},1000);
});
</script></p>
I cant find why i get this error because verify in the source code that:
because the script has been enqueed in the wp.
Anyone can help?
Regards

nvd3 not displaying graph for data with value of 1000 or higher

I am tring to set up analytics for email campaigns with a discrete bar graph and I just found out that nvd3 has a weird bug where any data point with a value of 1000 or higher doesnt get rendered right.
here is the jsfiddle
http://jsfiddle.net/aMnSb/
var data = [{
key: "Cumulative Return",
values: [
{"label" : "delivered","value" : "999","color" : "458ec1",},{"label" : "opened","value" : "176","color" : "65a1cb",},{"label" : "clicked","value" : "8","color" : "7fb1d4",},{"label" : "unopened","value" : "487","color" : "aacce3",},{"label" : "bounced","value" : "357","color" : "eec4cc",},{"label" : "unsubscribed","value" : "1","color" : "e39ba9",}, ]
}];
works , but this doesnt work
var data_large = [{
key: "Cumulative Return",
values: [
{"label" : "delivered","value" : "1000","color" : "458ec1",},{"label" : "opened","value" : "176","color" : "65a1cb",},{"label" : "clicked","value" : "8","color" : "7fb1d4",},{"label" : "unopened","value" : "487","color" : "aacce3",},{"label" : "bounced","value" : "357","color" : "eec4cc",},{"label" : "unsubscribed","value" : "1","color" : "e39ba9",}, ]
}];
You're seeing this behaviour because the numbers in your JSON aren't actually numbers, but strings (enclosed in quotes). It works if you remove the quotes around the numbers in the JSON.

Resources