Related
I know question has already asked but I can't do it with my get result.
My service get data from API return this kind of result :
{
"nhits": 581,
"parameters": {
"dataset": "communes-belges-2019",
"rows": 1,
"start": 0,
"facet": [
"niscode",
"region",
"nis_code_region"
],
"format": "json",
"timezone": "UTC"
},
"records": [
{
"datasetid": "communes-belges-2019",
"recordid": "65d40b7bc42f766b4fdb04c4a985766dc8b51717",
"fields": {
"shape_area": 79397718.576,
"mun_name_upper_fr": "ÉTALLE",
"arr_name_fr": "Virton",
"region": "Région wallonne",
"niscode": "85009",
"mun_off_language": "FR",
"geo_shape": {
"coordinates": [
[
[
5.678490965,
49.687217222
],
[
5.678462422,
49.6873304
]
]
],
"type": "Polygon"
},
"prov_name_fr": "Luxembourg",
"namefre": "Étalle",
"nom_commune": "Étalle",
"nis_code_region": "03000",
"mun_name_fr": "Étalle",
"reg_name_fr": "Région wallonne",
"mun_area_code": "BEL",
"modifdate": "2007-01-05",
"mun_type": "Commune/Gemeente/Gemeinde",
"mun_name_lower_fr": "étalle",
"prov_code": "80000",
"year": "2021-01-01",
"geo_point_2d": [
49.6639160352,
5.60896600843
]
},
"geometry": {
"type": "Point",
"coordinates": [
5.60896600843,
49.6639160352
]
},
"record_timestamp": "2019-05-24T09:44:14.333000+00:00"
}
],
"facet_groups": [
{
"name": "niscode",
"facets": [
{
"name": "11001",
"count": 1,
"state": "displayed",
"path": "11001"
},
{
"name": "33021",
"count": 1,
"state": "displayed",
"path": "33021"
},
{
"name": "33029",
"count": 1,
"state": "displayed",
"path": "33029"
},
{
"name": "33037",
"count": 1,
"state": "displayed",
"path": "33037"
}
]
},
{
"name": "region",
"facets": [
{
"name": "Région flamande",
"count": 299,
"state": "displayed",
"path": "Région flamande"
},
{
"name": "Région wallonne",
"count": 262,
"state": "displayed",
"path": "Région wallonne"
},
{
"name": "Région de Bruxelles-Capitale",
"count": 19,
"state": "displayed",
"path": "Région de Bruxelles-Capitale"
}
]
},
{
"name": "nis_code_region",
"facets": [
{
"name": "02000",
"count": 299,
"state": "displayed",
"path": "02000"
},
{
"name": "03000",
"count": 262,
"state": "displayed",
"path": "03000"
},
{
"name": "01000",
"count": 19,
"state": "displayed",
"path": "01000"
}
]
}
]
}
For the moment my service get data like this :
getProvinces(): Observable<any[]>{
return this._http.get<any>(this.apiProvinces)
.pipe(
map((response: any) => response.records as any[]),
catchError(this.handleError)
)
}
It returns a Observable<any[]> but I would like to get an object.
Therefore I defined a class with the below properties.
export class Record{
region : string;
nom_commune : string;
prov_name_fr: string;
records?: [];
constructor(reg: string, commune: string, prov: string) {
this.region = reg;
this.nom_commune = commune;
this.prov_name_fr = prov;
}
}
To reach that I try by replacing any[] by Record[] like below but it doesn't work.
getProvinces(): Observable<Record[]>{
return this._http.get<Record[]>(this.apiProvinces)
.pipe(
map(response => response as Record[]),
catchError(this.handleError)
)
}
In my component I defined an Observable<Record[]> like this :
public results$!: Observable<Record[]>;
And call the service like this :
this.results$ = this.apiService.getProvinces();
And try to see content in the html part:
<div *ngFor="let p of (results$ | async)">
{{p | json}}
</div>
I have the following error message : "Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays."
And can't access to my object.
Any suggestions is helpfull because. I'm absolutely new to ANgular.
Thanks
When you create an observable, you don't actually make a request to your api. To make the request and get the data from the observable, you need to subscribe.
this.apiService.getProvinces().subscribe((res) => (this.results = res));
This will execute the get request and return your data to the callback function. Get requests are finite observables, so you don't need to unsubscribe, but you will need to subscribe again if you want to make another request.
can someone please send me solution or link for PowerShell 5 and 7 how can I access child elements if specific condition is fulfilled for JSON file which I have as output.json. I haven't find it on the net.
I want to retrieve value of the "children" elements if type element has value FILE and to put that into some list. So final result should be [test1.txt,test2.txt]
Thank you!!!
{
"path": {
"components": [
"Packages"
],
"parent": "",
"name": "Packages",
},
"children": {
"values": [
{
"path": {
"components": [
"test1.txt"
],
"parent": "",
"name": "test1.txt",
},
"type": "FILE",
"size": 405
},
{
"path": {
"components": [
"test2.txt"
],
"parent": "",
"name": "test2.txt",
},
"type": "FILE",
"size": 409
},
{
"path": {
"components": [
"FOLDER"
],
"parent": "",
"name": "FOLDER",
},
"type": "DIRECTORY",
"size": 1625
}
]
"start": 0
}
}
1.) The json is incorrect, I assumt that this one is the correct one:
{
"path": {
"components": [
"Packages"
],
"parent": "",
"name": "Packages"
},
"children": {
"values": [
{
"path": {
"components": [
"test1.txt"
],
"parent": "",
"name": "test1.txt"
},
"type": "FILE",
"size": 405
},
{
"path": {
"components": [
"test2.txt"
],
"parent": "",
"name": "test2.txt"
},
"type": "FILE",
"size": 409
},
{
"path": {
"components": [
"FOLDER"
],
"parent": "",
"name": "FOLDER"
},
"type": "DIRECTORY",
"size": 1625
}
],
"start": 0
}
}
2.) The structure is not absolute clear, but for your example this seems to me to be the correct solution:
$element = $json | ConvertFrom-Json
$result = #()
$element.children.values | foreach {
if ($_.type -eq 'FILE') { $result += $_.path.name }
}
$result | ConvertTo-Json
Be aware, that the used construct $result += $_.path.name is fine if you have up to ~10k items, but for very large items its getting very slow and you need to use an arraylist. https://adamtheautomator.com/powershell-arraylist/
I need to output the JSON result in HTML so that I can use it in Coldfusion. I am getting the data but I do not know how to parse the returned data so that I can use it. I am a newby so be easy on me. I don't know JSON at all and this is the first time I am trying to work work this.
<cfset qpxFields = {
"request": {
"passengers": {
"adultCount": "1"
},
"slice": [
{
"origin": "JNB",
"destination": "MRU",
"date": "2016-12-19"
}
],
"solutions": "1"
}
}/>
<cfhttp url="https://www.googleapis.com/qpxExpress/v1/trips/search?key=AIzaSyB0NN9WYmrkc2Ikq9TVGzzAD_gGoSBSbP4" method="post" result="httpResp" timeout="60">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="body" value="#serializeJSON(qpxFields)#">
</cfhttp>
<cfset getResult = deserializeJSON(httpResp.filecontent)>
<cfoutput>#httpResp.filecontent#</cfoutput>
The result I am getting when outputting the filecontent is the following:
{ "kind": "qpxExpress#tripsSearch", "trips": { "kind": "qpxexpress#tripOptions", "requestId": "ylROS8N2kR4vI8ktC0PQVj", "data": { "kind": "qpxexpress#data", "airport": [ { "kind": "qpxexpress#airportData", "code": "JNB", "city": "JNB", "name": "Johannesburg O.R. Tambo International" }, { "kind": "qpxexpress#airportData", "code": "MRU", "city": "MRU", "name": "Mauritius Sir S. Ramgoolam International" } ], "city": [ { "kind": "qpxexpress#cityData", "code": "JNB", "name": "Johannesburg" }, { "kind": "qpxexpress#cityData", "code": "MRU", "name": "Mauritius" } ], "aircraft": [ { "kind": "qpxexpress#aircraftData", "code": "343", "name": "Airbus A340" } ], "tax": [ { "kind": "qpxexpress#taxData", "id": "EV_001", "name": "South Africa Passenger Safety Charge" }, { "kind": "qpxexpress#taxData", "id": "YQ_F", "name": "MK YQ surcharge" }, { "kind": "qpxexpress#taxData", "id": "YR_I", "name": "MK YR surcharge" }, { "kind": "qpxexpress#taxData", "id": "ZA_001", "name": "South Africa Passenger Service Charge" }, { "kind": "qpxexpress#taxData", "id": "UM_001", "name": "South Africa Asc Charge" }, { "kind": "qpxexpress#taxData", "id": "WC_001", "name": "South Africa Air Passenger Tax" } ], "carrier": [ { "kind": "qpxexpress#carrierData", "code": "MK", "name": "AIR MAURITIUS LTD" } ] }, "tripOption": [ { "kind": "qpxexpress#tripOption", "saleTotal": "ZAR5398.23", "id": "bGXAC5TFGRFO06xEFBzMaA001", "slice": [ { "kind": "qpxexpress#sliceInfo", "duration": 240, "segment": [ { "kind": "qpxexpress#segmentInfo", "duration": 240, "flight": { "carrier": "MK", "number": "852" }, "id": "GB3DFc4zHshnkF7H", "cabin": "COACH", "bookingCode": "T", "bookingCodeCount": 9, "marriedSegmentGroup": "0", "leg": [ { "kind": "qpxexpress#legInfo", "id": "LwsDBsjHUFZrYe5Y", "aircraft": "343", "arrivalTime": "2016-12-19T19:35+04:00", "departureTime": "2016-12-19T13:35+02:00", "origin": "JNB", "destination": "MRU", "originTerminal": "B", "duration": 240, "mileage": 1904, "meal": "Meal" } ] } ] } ], "pricing": [ { "kind": "qpxexpress#pricingInfo", "fare": [ { "kind": "qpxexpress#fareInfo", "id": "AdGb1tIdX7T9uIyT9qTU9OFHTXhaVL0C0ojKd7a7use6", "carrier": "MK", "origin": "JNB", "destination": "MRU", "basisCode": "TAANOWMU" } ], "segmentPricing": [ { "kind": "qpxexpress#segmentPricing", "fareId": "AdGb1tIdX7T9uIyT9qTU9OFHTXhaVL0C0ojKd7a7use6", "segmentId": "GB3DFc4zHshnkF7H" } ], "baseFareTotal": "ZAR3690.00", "saleFareTotal": "ZAR3690.00", "saleTaxTotal": "ZAR1708.23", "saleTotal": "ZAR5398.23", "passengers": { "kind": "qpxexpress#passengerCounts", "adultCount": 1 }, "tax": [ { "kind": "qpxexpress#taxInfo", "id": "ZA_001", "chargeType": "GOVERNMENT", "code": "ZA", "country": "ZA", "salePrice": "ZAR346.00" }, { "kind": "qpxexpress#taxInfo", "id": "EV_001", "chargeType": "GOVERNMENT", "code": "EV", "country": "ZA", "salePrice": "ZAR20.23" }, { "kind": "qpxexpress#taxInfo", "id": "UM_001", "chargeType": "GOVERNMENT", "code": "UM", "country": "ZA", "salePrice": "ZAR24.00" }, { "kind": "qpxexpress#taxInfo", "id": "WC_001", "chargeType": "GOVERNMENT", "code": "WC", "country": "ZA", "salePrice": "ZAR190.00" }, { "kind": "qpxexpress#taxInfo", "id": "YQ_F", "chargeType": "CARRIER_SURCHARGE", "code": "YQ", "salePrice": "ZAR1090.00" }, { "kind": "qpxexpress#taxInfo", "id": "YR_I", "chargeType": "CARRIER_SURCHARGE", "code": "YR", "salePrice": "ZAR38.00" } ], "fareCalculation": "JNB MK MRU 260.69TAANOWMU NUC 260.69 END ROE 14.15458 FARE ZAR 3690.00 XT 20.23EV 24.00UM 190.00WC 346.00ZA 1090.00YQ 38.00YR", "latestTicketingTime": "2016-12-19T06:34-05:00", "ptc": "ADT", "refundable": true } ] } ] } }
I am using CF 10.
Instead of trying to deal with the HTTP response (httpResp.filecontent) look at your deserialized content (getResult). You cannot simply output that variable as ColdFusion creates a structure from the JSON data.
Dump out your deserialzed JSON like this:
<cfdump var="#getResult#">
Looking at that output you will see how ColdFusion has already parsed all of the information for you. You are going to have some structure values and some array values. You will need to use appropriate methods (looping over an array for example) to extract each individual piece of data.
Reply to your comment
Looping in ColdFusion is well documented. To get you started you can look at the Adobe documentation itself - cfloop. The documentation on that page shows how to link over arrays, structures, etc.
Another good reference is Learn CF In a Week - looping.
Looping works when you have to traverse one-dimensional or two-dimensional structs or arrays. When the data combines structs and arrays in 3 or more dimensions, as in this particular problem, then looping is often insufficient as a solution. The complexity will certainly overwhelm most beginners.
A good solution is to play dumb. Start with the result, the structure getResult. Do a dump, as suggested by others earlier. Then simply run through it by eye and drill down to the values.
The list of values is:
getResult.kind
getResult.trips.data.aircraft[1].code
getResult.trips.data.aircraft[1].kind
getResult.trips.data.aircraft[1].name
getResult.trips.data.airport[1].city
getResult.trips.data.airport[1].code
getResult.trips.data.airport[1].kind
getResult.trips.data.airport[1].name
getResult.trips.data.airport[2].city
getResult.trips.data.airport[2].code
getResult.trips.data.airport[2].kind
getResult.trips.data.airport[2].name
getResult.trips.data.carrier[1].code
getResult.trips.data.carrier[1].kind
getResult.trips.data.carrier[1].name
getResult.trips.data.city[1].code
getResult.trips.data.city[1].kind
getResult.trips.data.city[1].name
getResult.trips.data.city[2].code
getResult.trips.data.city[2].kind
getResult.trips.data.city[2].name
getResult.trips.data.kind
getResult.trips.data.tax[1].id
getResult.trips.data.tax[1].kind
getResult.trips.data.tax[1].name
getResult.trips.data.tax[2].id
getResult.trips.data.tax[2].kind
getResult.trips.data.tax[2].name
getResult.trips.data.tax[3].id
getResult.trips.data.tax[3].kind
getResult.trips.data.tax[3].name
getResult.trips.data.tax[4].id
getResult.trips.data.tax[4].kind
getResult.trips.data.tax[4].name
getResult.trips.data.tax[5].id
getResult.trips.data.tax[5].kind
getResult.trips.data.tax[5].name
getResult.trips.data.tax[6].id
getResult.trips.data.tax[6].kind
getResult.trips.data.tax[6].name
getResult.trips.kind
getResult.trips.requestId
getResult.trips.tripOption[1].id
getResult.trips.tripOption[1].kind
getResult.trips.tripOption[1].saletotal
getResult.trips.tripOption[1].pricing[1].basefareTotal
getResult.trips.tripOption[1].pricing[1].fare[1].basiscode
getResult.trips.tripOption[1].pricing[1].fare[1].carrier
getResult.trips.tripOption[1].pricing[1].fare[1].destination
getResult.trips.tripOption[1].pricing[1].fare[1].id
getResult.trips.tripOption[1].pricing[1].fare[1].kind
getResult.trips.tripOption[1].pricing[1].fare[1].origin
getResult.trips.tripOption[1].pricing[1].fareCalculation
getResult.trips.tripOption[1].pricing[1].kind
getResult.trips.tripOption[1].pricing[1].latestTicketingTime
getResult.trips.tripOption[1].pricing[1].passengers.adultCount
getResult.trips.tripOption[1].pricing[1].passengers.kind
getResult.trips.tripOption[1].pricing[1].ptc
getResult.trips.tripOption[1].pricing[1].refundable
getResult.trips.tripOption[1].pricing[1].saleFareTotal
getResult.trips.tripOption[1].pricing[1].saletaxTotal
getResult.trips.tripOption[1].pricing[1].saleTotal
getResult.trips.tripOption[1].pricing[1].segmentPricing[1].fareId
getResult.trips.tripOption[1].pricing[1].segmentPricing[1].kind
getResult.trips.tripOption[1].pricing[1].segmentPricing[1].segmentId
getResult.trips.tripOption[1].pricing[1].tax[1].chargeType
getResult.trips.tripOption[1].pricing[1].tax[1].code
getResult.trips.tripOption[1].pricing[1].tax[1].country
getResult.trips.tripOption[1].pricing[1].tax[1].id
getResult.trips.tripOption[1].pricing[1].tax[1].kind
getResult.trips.tripOption[1].pricing[1].tax[1].salePrice
getResult.trips.tripOption[1].pricing[1].tax[2].chargeType
getResult.trips.tripOption[1].pricing[1].tax[2].code
getResult.trips.tripOption[1].pricing[1].tax[2].country
getResult.trips.tripOption[1].pricing[1].tax[2].id
getResult.trips.tripOption[1].pricing[1].tax[2].kind
getResult.trips.tripOption[1].pricing[1].tax[2].salePrice
getResult.trips.tripOption[1].pricing[1].tax[3].chargeType
getResult.trips.tripOption[1].pricing[1].tax[3].code
getResult.trips.tripOption[1].pricing[1].tax[3].country
getResult.trips.tripOption[1].pricing[1].tax[3].id
getResult.trips.tripOption[1].pricing[1].tax[3].kind
getResult.trips.tripOption[1].pricing[1].tax[3].salePrice
getResult.trips.tripOption[1].pricing[1].tax[4].chargeType
getResult.trips.tripOption[1].pricing[1].tax[4].code
getResult.trips.tripOption[1].pricing[1].tax[4].country
getResult.trips.tripOption[1].pricing[1].tax[4].id
getResult.trips.tripOption[1].pricing[1].tax[4].kind
getResult.trips.tripOption[1].pricing[1].tax[4].salePrice
getResult.trips.tripOption[1].pricing[1].tax[5].chargeType
getResult.trips.tripOption[1].pricing[1].tax[5].code
getResult.trips.tripOption[1].pricing[1].tax[5].id
getResult.trips.tripOption[1].pricing[1].tax[5].kind
getResult.trips.tripOption[1].pricing[1].tax[5].salePrice
getResult.trips.tripOption[1].pricing[1].tax[6].chargeType
getResult.trips.tripOption[1].pricing[1].tax[6].code
getResult.trips.tripOption[1].pricing[1].tax[6].id
getResult.trips.tripOption[1].pricing[1].tax[6].kind
getResult.trips.tripOption[1].pricing[1].tax[6].salePrice
getResult.trips.tripOption[1].saletotal
getResult.trips.tripOption[1].slice[1].duration
getResult.trips.tripOption[1].slice[1].kind
getResult.trips.tripOption[1].slice[1].segment[1].bookingCode
getResult.trips.tripOption[1].slice[1].segment[1].bookingCodeCount
getResult.trips.tripOption[1].slice[1].segment[1].cabin
getResult.trips.tripOption[1].slice[1].segment[1].duration
getResult.trips.tripOption[1].slice[1].segment[1].flight.carrier
getResult.trips.tripOption[1].slice[1].segment[1].flight.number
getResult.trips.tripOption[1].slice[1].segment[1].id
getResult.trips.tripOption[1].slice[1].segment[1].kind
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].aircraft
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].arrivalTime
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].departureTime
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].destination
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].duration
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].id
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].kind
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].meal
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].mileage
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].origin
getResult.trips.tripOption[1].slice[1].segment[1].leg[1].originTerminal
getResult.trips.tripOption[1].slice[1].segment[1].marriedSegmentGroup
I'm having difficulty processing external JSON data to build/dispaly a tree. The issue is that nodes are not built from received JSON file. The code only looks as at the JSON data as one object and does not create leafs(other nodes)
When adding the same JSON data as array inside HTML file, the same code creates nodes and displays the tree correctly.
Here is an extract of the code in question:
<body onload="myFunction()">
<script type="text/javascript" >
function myFunction()
{
d3.json("/data/mydata.json", function (error, data) {
var root2 = [data];
root = root2[0];
........... other stuff comes here .....
var nodes = tree.nodes(root.reverse());
The browser debugger gives me the following:
nodes
[Array[1]0: Object
childern: Array[2]
name: "Max"
parent: "null"
proto: Object
depth: 0
length: 1
x: 230
y: 0
proto: Array[0]
JOSN file is at the bottom
I appreciate your feedback in this regard.
[{
"name": "Max",
"parent": "null",
"size": 4938,
"childern": [
{
"name": "David",
"parent": "Max",
"Childern": [
{
"name": "Craig",
"parent": "David",
"size": 3938
},
{
"name": "Robin",
"parent": "David",
"size": 3812
},
{
"name": "Anna",
"parent": "David",
"size": 743
}
]
},
{
"name": "Peter",
"parent": "Max",
"Childern": [
{
"name": "Jeff",
"parent": "Peter",
"size": 3534
},
{
"name": "Buffy",
"parent": "Peter",
"size": 5731
}
]
}
]
}
]
Your external JSON file appears to have the 'children' element with a capital 'C' for the lower tiers of data, but with lower case 'c' at the top tier.
Additionally they were misspelled as 'Childern' which may have been causing problems (you will want to check your JavaScript to see how you spelled it there and make it consistent).
I was able to do a quick experiment with an external JSON file and I can confirm that you will get a problem similar to what you describe. So use lower case characters (or at least consistent characters and spelling) for the word 'children' in your data.
Try with the data per below;
[{
"name": "Max",
"parent": "null",
"size": 4938,
"children": [
{
"name": "David",
"parent": "Max",
"children": [
{
"name": "Craig",
"parent": "David",
"size": 3938
},
{
"name": "Robin",
"parent": "David",
"size": 3812
},
{
"name": "Anna",
"parent": "David",
"size": 743
}
]
},
{
"name": "Peter",
"parent": "Max",
"children": [
{
"name": "Jeff",
"parent": "Peter",
"size": 3534
},
{
"name": "Buffy",
"parent": "Peter",
"size": 5731
}
]
}
]
}
I want to index & search nested json in solr. Here is my json code
{
"id": "44444",
"headline": "testing US",
"generaltags": [
{
"type": "person",
"name": "Jayalalitha",
"relevance": "0.334",
"count": 1
},
{
"type": "person",
"name": "Kumar",
"relevance": "0.234",
"count": 1
}
],
"socialtags": {
"type": "SocialTag",
"name": "US",
"importance": 2
},
"topic": {
"type": "Topic",
"name": "US",
"score": "0.936"
}
}
When I try to Index, I'm getting the error "Error parsing JSON field value. Unexpected OBJECT_START"
When we tried to use Multivalued Field & index, we couldn't able to search using the multivalued field? Its returning "Undefined Field"
Also Please advice if I need to do any changes in schema.xml file?
You are nesting child documents within your document. You need to use the proper syntax for nested child documents in JSON:
[
{
"id": "1",
"title": "Solr adds block join support",
"content_type": "parentDocument",
"_childDocuments_": [
{
"id": "2",
"comments": "SolrCloud supports it too!"
}
]
},
{
"id": "3",
"title": "Lucene and Solr 4.5 is out",
"content_type": "parentDocument",
"_childDocuments_": [
{
"id": "4",
"comments": "Lots of new features"
}
]
}
]
Have a look at this article which describes JSON child documents and block joins.
Using the format mentioned by #qux you will face "Expected: OBJECT_START but got ARRAY_START at [16]",
"code": 400
as when JSON starting with [....] will parsed as a JSON array
{
"id": "44444",
"headline": "testing US",
"generaltags": [
{
"type": "person",
"name": "Jayalalitha",
"relevance": "0.334",
"count": 1
},
{
"type": "person",
"name": "Kumar",
"relevance": "0.234",
"count": 1
}
],
"socialtags": {
"type": "SocialTag",
"name": "US",
"importance": 2
},
"topic": {
"type": "Topic",
"name": "US",
"score": "0.936"
}
}
The above format is correct.
Regarding searching. Kindly use the index to search for the elements of the JSON array.
The workaround for this can be keeping the whole JSON object inside other JSON object and the indexing it
I was suggesting to keep the whole data inside another JSON object. You can try the following way
{
"data": [
{
"id": "44444",
"headline": "testing US",
"generaltags": [
{
"type": "person",
"name": "Jayalalitha",
"relevance": "0.334",
"count": 1
},
{
"type": "person",
"name": "Kumar",
"relevance": "0.234",
"count": 1
}
],
"socialtags": {
"type": "SocialTag",
"name": "US",
"importance": 2
},
"topic": {
"type": "Topic",
"name": "US",
"score": "0.936"
}
}
]
}
see the syntax in http://yonik.com/solr-nested-objects/
$ curl http://localhost:8983/solr/demo/update?commitWithin=3000 -d '
[
{id : book1, type_s:book, title_t : "The Way of Kings", author_s : "Brandon Sanderson",
cat_s:fantasy, pubyear_i:2010, publisher_s:Tor,
_childDocuments_ : [
{ id: book1_c1, type_s:review, review_dt:"2015-01-03T14:30:00Z",
stars_i:5, author_s:yonik,
comment_t:"A great start to what looks like an epic series!"
}
,
{ id: book1_c2, type_s:review, review_dt:"2014-03-15T12:00:00Z",
stars_i:3, author_s:dan,
comment_t:"This book was too long."
}
]
}
]'
supported from solr 5.3