How to access a json field with dot in name - admin-on-rest

I have a sample json to show as follows
how I can display a field "connector.class"?
If I use , it will show nothing since it interpreted as nest json.
{
"connector.class" : "FileGenericSourceConnector",
"schema.registry.uri" : "http://localhost:8081",
"cuid" : "597bd1dc7985373920904f81",
"file.location" : "/home/vagrant/df_data/",
"tasks.max" : "1",
"file.glob" : "*.{json,csv}",
"file.overwrite" : "true",
"schema.subject" : "test_value",
"topic" : "stock"
}

Finally, got this working by using [' '] in rest-on-admin
<LongTextInput source="connectorConfig.['connector.class']" label="Class Name" />

You can use the AOR FunctionField
https://marmelab.com/admin-on-rest/Fields.html#functionfield
<FunctionField label="Connector Class" render={record => {record.connector.class} />

Related

NiFi Route on JSON Attribute

Trying to use NiFi to route on an attribute.
I am attempting to take a json file, where two of the json records contain the following attributes (there are other json documents with different attributes in this file):
{
"ts" : "2020-010-07T12:00:00.448392Z",
"uid" : "CHh3F30dkfueLhnxSk",
"id.orig_h" : "10.10.10.10",
"id.orig_p" : 19726,
"id.resp_h" : "172.10.10.20",
"id.resp_p" : 443,
"proto" : "tcp",
"conn_state" : "SH",
"local_orig" : false,
"local_resp" : false,
"missed_bytes" : 0,
"history" : "F",
"orig_pkts" : 1,
"orig_ip_bytes" : 52,
"resp_pkts" : 0,
"resp_ip_bytes" : 0}
{
"ts" : "2020-10-10T12:00:00.461880Z",
"uid" : "CdoiLnRscrxO1BSYb",
"id.orig_h" : "10.10.17.777",
"id.orig_p" : 40433,
"id.resp_h" : "172.10.10.77",
"id.resp_p" : 443,
"version" : "TLSv12",
"cipher" : "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"curve" : "secp777r1",
"server_name" : "connect-stackoverflow.questions.com",
"resumed" : false,
"established" : true,
"cert_chain_fuids" : [ "FR84qjkl2342SZLwV7", "Ffweqiof48b8j" ],
"client_cert_chain_fuids" : [ ],
"subject" : "CN=connect-ulastm.bentley.com",
"issuer" : "CN=Let's Encrypt Authority X3,O=Let's Encrypt,C=US",
"validation_status" : "ok"}
I want to specifically route on the $.conn_state attribute but it is not working. I have tried to match the expression with the evaluateJSONpath processor and passed it to routeOnAttribute. Here are my settings:
evaluateJSONpath processor:
The above processor does not match the json and forward the document
and the evaluateJSONpath is followed by the routeOnAttribute processor:
I have attempted to routeOnAttribute directly from my jsonRecord, but it does not appear to pull out or identify the attribute for routing...
How would I do this?
#Advent United
The JSON sample is more than one object, your evaluateJson is going to expect a single record in matching $.conn_state. For multiple record work against json or any data stream you should use QueryRecord. Once configured w/ record reader and record writer within in that processor you just click + to create the route and the value is the select statement where conn_state is not null. Then you can drag that route to the next processor.

document field returns null when querying groups of Prismic Content-Realtionship fields in graphql

Issue:
I am using Prismic to send data through to my website.
In Prismic I have a Type (testimonial_list) that consists of a group of content-relation fields (Prismic Type testimonials).
To query the data on the inner Types I need to access them via the document field in graphql and use inline-fragments.
I have followed as instructed here:
https://github.com/angeloashmore/gatsby-source-prismic#Query-Content-Relation-fields
Inside graphql I have managed to navigate to the testimonial data-fields (on the document field) but the document field returns null, this is where I'm stuck. I can't work out why it would return null as the content exists and the fields are clearly being found in graphql.
Info:
My project is built using Gatsby and I'm using the plugin gatsby-source-prismic v3.1.1
Here you can see I can access the correct field data and I am getting the right number of nodes returned but document is empty:
This is the JSON for the testimonial_list Type on Prismic:
{
"Main" : {
"prismic_title" : {
"type" : "StructuredText",
"config" : {
"single" : "heading6",
"label" : "Title (only used to name entry in Prismic list)",
"placeholder" : "Prismic list title (otherwise \"undefined\")"
}
},
"page" : {
"type" : "Select",
"config" : {
"options" : [ "Homepage", "Option 2", "Option 3" ],
"label" : "Website page to appear on:"
}
},
"testimonial_list" : {
"type" : "Group",
"config" : {
"fields" : {
"testimonial" : {
"type" : "Link",
"config" : {
"select" : "document",
"customtypes" : [ "testimonial" ],
"label" : "testimonial"
}
}
},
"label" : "Testimonial List"
}
}
}
}
Thank you for any help, if there is any more info I can supply to help deduce the issue please let me know.
In the end, the issue turned out to be a typo in my gatsby-config where I was requiring the schema.
It was a daft mistake but stare at something too long and these things happen I guess.
In case anybody else has a similar issue you must ensure the property names of your Prismic schemas inside your gatsby-config are exactly the same as in Prismic.
For example if your Type in Prismic is called "my_type" then you must use that exact syntax - so for example don't use "myType".
Hey it might be something related to the gatsby-source-prismic plugin
I would directly open an issue for it here if I were you: https://github.com/angeloashmore/gatsby-source-prismic/issues

How to store nested document as String in elastic search

Context:
1) We are building a CDC pipeline (using kafka & connect framework)
2) We are using debezium for capturing mysql Tx logs
3) We are using Elastic Search connector to add documents to ES index
Sample change event generated by Debezium:
{
"source" : {
"before" : {
"Id" : 97,
"name" : "Northland",
"code" : "NTL",
"country_id" : 6,
"is_business_mapped" : 0
},
"after" : {
"Id" : 97,
"name" : "Northland",
"code" : "NTL",
"country_id" : 6,
"is_business_mapped" : 1
},
"source" : {
"version" : "0.7.5",
"name" : "__",
"server_id" : 252639387,
"ts_sec" : 1547805940,
"gtid" : null,
"file" : "mysql-bin-changelog.000570",
"pos" : 236,
"row" : 0,
"snapshot" : false,
"thread" : 614,
"db" : "bazaarify",
"table" : "state"
},
"op" : "u",
"ts_ms" : 1547805939683
}
What we want :
We want to visualize only 3 columns in kibana :
1) before - containing the nested JSON as string
2) after - containing the nested JSON as string
3) source - containing the nested JSON as string
I can think below possibilities here :
a) Either converting nested JSON as string
b) Combining column data in elastic search
I am a newbie to elastic search . Can someone please guide me how to do that.
I tried defining custom mapping as well but it is giving me exception.
You can always view your document as a Raw JSON in Kibana.
You don't need to manipulate it before indexing in elastic.
As this is related to visualization, handle this in Kibana only.
Check this link for a screenshot.
Refer this to add the columns which you want to see onto the results
I don't fully understand your use case, but if you would like to turn some json's to their representing strings, then you can use logstash for that, or even Elasticsearch ingest capabilities to convert an object (json) to a string.
From the link above, an example:
PUT _ingest/pipeline/my-pipeline-id { "description": "converts the
content of the id field to an integer", "processors" : [
{
"convert" : {
"field" : "source",
"type": "string"
}
} ] }

Querying for specific strings in Firebase?

I have a database which looks something like this:
"trucks" : {
"3705ec54-8a2e-4eb1-8bb9-ab2243645ac1" : {
"email" : "sandwiches#123.com",
"name" : "Sandwich Truck",
"phone" : "123 - 456 - 1234",
"provider" : "password",
"selfDescription" : "We serve delicious sandwiches at a moderate price. Cards Accepted.",
"userType" : "truck",
"website" : "www.sandwiches.com"
},
"54fea8cd-2203-46bd-aaf8-9d823e85313d" : {
"email" : "pizza#123.com",
"name" : "Supa Pizza",
"phone" : "619 - 222 - 4444",
"provider" : "password",
"selfDescription" : "We serve incredible pizza at an incredibly unfair price.",
"userType" : "truck",
"website" : ""
},
"6c542367-507c-4d01-af2c-bf93a7efaef4" : {
"email" : "fries#123.com",
"name" : "Pete's Fries",
"phone" : "11111111111111111111",
"profilePhoto" : "",
"provider" : "password",
"selfDescription" : "We make some of the world's most delicious fries.",
"userType" : "truck",
"website" : ""
},
"7c6c4395-aec1-443c-908d-62db517def5e" : {
"email" : "chili#123.com",
"name" : "Mark's Chili",
"phone" : "1-800-CHIL-LLL",
"profilePhoto" : "",
"provider" : "password",
"selfDescription" : "We serve the most delicious chili, chili your mamma's mamma is scared to try.",
"userType" : "truck",
"website" : ""
}
}
I'd like to implement a search bar for which trucks whose names match the search terms will be returned. For example, any truck name containing the string 'fries' will have its ID committed to an array of search result IDs.
Here's what I've tried so far, but no dice. When I type in fries in my searchbar and hit the search button, it does not print "6c542367-507c-4d01-af2c-bf93a7efaef4"
let usersRef = Firebase(url: "https://•••••••••.firebaseIO.com/users")
usersRef.queryOrderedByChild("name").queryEqualToValue(searchBar.text).observeEventType(.ChildAdded, withBlock:{
snapshot in
print(snapshot.key)
})
I'm not even sure how close I am, any help would be massively appreciated.
Thanks!
You are querying using queryEqualToValue (Query.equalTo()), which will return result only if there is an exact match.
Explanation in Detail:
In the search bar if we are entering "fries" it will look for an exact match of "fries", which is not available in our document and hence the desired value "6c542367-507c-4d01-af2c-bf93a7efaef4" is not printed.
Instead if we give the value "Pete's Fries" in the search bar then we will get the result "6c542367-507c-4d01-af2c-bf93a7efaef4"
If we give partial value for our search, then we are trying to implement a search which is similar to LIKE Query in SQL. Please refer the below posts to get more info on "how to perform LIKE query in firebase"
How to perform sql "LIKE" operation on firebase?

mongodb ruby :Updating a field within a nested document

I have a document in mongodb with the following structure.
{
"_id" : ObjectId("52ad477a5873b710c0000007"),
"ad_name" : "name_6",
"selected" : true,
"vendor" : "facebook.com",
"status" : "VALID",
"ad_details" : {
"Body" : "something",
"Title" : "random_6",
"Url" : "www.someurl.com",
"Image" : "blob_data"
}
}
i want to update the field name "selected" and the field "Url" in one query.Currently i can update selected field but not Url.
ads.update({"_id" => BSON::ObjectId.from_string(doc_id)},
{"$set"=> {"selected" => select, "Url" => params["urls"][indx]}}
This query does not give me any error but doesnt update the Url as it is present inside ad_details sub-document. Also i DO NOT WANT to update entire ad_details json which is one way of doing it.Please help!!
You just need to specify the path to the value you want to update:
'$set' => { 'ad_details.Url' => params['urls'][idx], ... }

Resources