I want to tie a folder with multiple images to my data.
I have some data:
[
{
"title": "data1",
"images" : "./relimages/first-data/",
"cardimages" : "./relimages/main-page-card-images/1.jpg",
},
{
"title": "data2",
"images" : "./relimages/second-data/",
"cardimages" : "./relimages/main-page-card-images/2.jpg",
},
{
"title": "data3",
"images" : "./relimages/third-data/",
"cardimages" : "./relimages/main-page-card-images/3.jpg",
}
]
But when I query them with graphql, I only have a string : "./relimages/first-data"
Although, my cardimages data entry is seen as an image directly.
How can I make my query see that as a folder, instead of just returning the string.
I want this code to work:
<h1>{data.title}</h1>
data.images.edges.map(image => return (<img src={image.node.childImageSharp.fluid.src}/>))
Here's my current GraphQL query:
query flagquery {
allDataRoJson {
edges {
node {
images {
edges {
node {
childImageSharp {
fluid {
src
}
}
}
}
cardimages {
id
childImageSharp {
fluid {
originalImg
}
}
}
}
}
}
}
}
But my image data entry is seen as a string, instead of a folder. Is this possible somehow?
Error is:
Field \"images\" must not have a selection since type \"String\" has no subfields
Related
I have a json file with the following data:
{
"Index" : {
"example_user" : {
"important_key" : "leave_me_alone",
"blah" : {
"more_stuff" : {
"ignore_this" : "and_this_too"
}
}
},
"another_user" : {
"blah" : {
"more_stuff" : {
"ignore_this" : "and_this_too"
}
}
},
"extra_person" : {
"blah" : {
"more_stuff" : {
"ignore_this" : "and_this_too"
}
}
}
}
}
As you can see, important_key is missing from another_user and extra_person.
My goal is to conditionally add "imporant_key" : "" where it is missing but not replace any existing important_key values. The program i use is JQ (1.6) from https://stedolan.github.io/jq/.
After many failed attempts on jqplay.org and having intensively (re)searched the internet on how to get the job done , i've only managed to realize the following:
Filter:.Index[]+={"important_key":"data"}
Result
{
"Index": {
"example_user": {
"important_key": "data",
"blah": {
"more_stuff": {
"ignore_this": "and_this_too"
}
}
},
"another_user": {
"blah": {
"more_stuff": {
"ignore_this": "and_this_too"
}
},
"important_key": "data"
},
"extra_person": {
"blah": {
"more_stuff": {
"ignore_this": "and_this_too"
}
},
"important_key": "data"
}
}
}
I'm aware += (over)writes any existing key value (note example_user). I've been experimenting with multiple piped filters/operators, including |= and { }, but in the end, the above result was the closest i could get.
(unfortunately i can't seem to find the jqplay code snippet where i went "crazy" with everything)
The moment you have to conditionally do something, you have to do some sort of filtering, either using if or select or other means.
For every object you wish to inspect, check if the object has your important_key and add it when necessary. If it has the key, do nothing, otherwise set it.
.Index[] |= if has("important_key") then . else .important_key = $myImportantKey end
I would like to convert this JSON
{
"l1k1": {
"l2k1": "l2v1",
"l2k2": 1
},
"l1k2": [
{
"e1l1": "e1v1",
"e1l2": "e1v2"
},
{
"e2l1": "e2v1",
"e2l2": "e2v2"
}
]
}
to this one
{
"papa": {
"l1k1c": {
"l2k1c": {
"string": "l2v1"
},
"l2k2c": {
"int": 1
}
},
"l1k2c": {
"array": [
{
"e1l1": "e1v1",
"e1l2": "e1v2"
},
{
"e2l1": "e2v1",
"e2l2": "e2v2"
}
]
}
}
}
where:
"l" stands for level
"k" for key, "v" for value
"e" for element
"c" for copy (where "*" maps to "*c")
I'm using circe's Json but having a hard time renaming the keys or creating parents or children with it. As I'm writing this, I'm thinking I may need to use its ACursor instead. As you may have guessed, I'm trying to generate an AVRO doc from an input JSON. I'm open to help w/ my approach or any suggestions about how to go about it in a cleaner way.
I am struggling with Firestore REST API. Database have a collection with Users. Every user is separate document. I need to get all users with, for example, category equal 1. Here is my attempt (request body):
{
"structuredQuery": {
"where" : {
"fieldFilter" : {
"field": { "fieldPath" : "category" } ,
"op":"EQUAL",
"value": { "integerValue" : 1 }
}
}
}
}
and response error:
"error": {
"code": 400,
"message": "kind is required for filter: category",
"status": "INVALID_ARGUMENT"
}
I have totaly no idea, how "field" inside "fieldFilter" should looks like. Thanks in advance.
I believe if you include the "from" property of the structured query, this will work. If the collection you're querying from is called "users" it would look like this, based on what you posted above:
{
"structuredQuery": {
"where" : {
"fieldFilter" : {
"field": {"fieldPath": "category"},
"op":"EQUAL",
"value": {"integerValue": 1}
}
},
"from": [{"collectionId": "users"}]
}
}
I am trying to create an index in Elasticsearch for the JSON file of format:
{ "index" : { "_index" : "entity", "_type" : "type1", "_id" : "0" } }
{ "eid":"guid of Event autogenerated", "entityInfo": { "entityType":"qualityevent", "defaultLocale":"en-US" }, "systemInfo": { "tenantId":"67" }, "attributesInfo" : { "jobId":"21", "matchStatus": "new" } }
{ "index" : { "_index" : "entity", "_type" : "type1", "_id" : "1" } }
{ "eid":"guid of Event autogenerated", "entityInfo": { "entityType":"qualityevent", "defaultLocale":"en-US" }, "systemInfo": { "tenantId":"67" }, "attributesInfo" : { "jobId":"20", "matchStatus": "existing" } }
I want the fields jobId and tenantId to be integers.
I am giving the following mapping in curl command:
curl -XPUT http://localhost:9200/entity -d '
{
"mappings": {
"entityInfo":
{
"properties" : {
"entityType" : { "type":"string","index" : "not_analyzed"},
"defaultLocale":{ "type":"string","index" : "not_analyzed"}
}
},
"systemInfo":
{
"properties" : {
"tenantId": { "type" : "integer" }
}
},
"attributesInfo" :
{
"properties" : {
"jobId": { "type" : "integer" },
"matchStatus": { "type":"string","index" : "not_analyzed"}
}
}
}
}
';
This does not give me an error. However, it creates new empty fields jobId and tenantId as integers and it keeps the existing data into attributesInfo.jobId as string. Same is the case with systemInfo.tenantId. I want to use these two fields in Kibana for visualization. I currently cannot use them as they are empty.
I am new to Kibana and Elasticsearch so I am not sure if the mapping is correct.
I have tried couple of other mappings as well but they give errors. Above mapping does not give error.
This is how Discover Tab on Kibana looks like: 1
Please let me know where I am going wrong.
I tried as you mentioned but it didn't help. What I realised after a lot of trial and error that my mapping was incorrect. I finally wrote the correct mapping and now it works correctly. Jobid and TenantId are recognised as numbers by Kibana. I am new to JSON, kibana, Bulk, Elastic so it took time to understand how mapping works.
I define a template.json file like this:
{ "id":1,
"licence":
{
"province":"BeiJin",
"number":"RB03718"
}
}
define cars.json like this:
{
"cars":[]
}
then load them all
rapidjson::Document car,cars;
loadJson(car, "template.json"); //load the json file from disk
loadJson(cars,"cars.json");
auto & allocator=cars.GetAllocator();
cars.PushBack(car , allocator);
try to get something like this in cars
{
"car": [
{ "id":1,
"licence":
{
"province":"BeiJin",
"number":"RB03718"
}
}
]
}
but as the car document get out of life cycle. element in cars array breaks down.
how could I solve this problem?