Solr schema with nested object - solr

I am using solr 5.5 version in single instance. I am trying to index the below data as one record:
{
"MLId": "00021BF6-BCC7-4F2E-8B8F-02587310A1B4",
"PublishDate": "2015-06-03",
"CompanyName": "GLI Finance Limited",
"Ticker": "GLI",
"Primary": "1",
"Exchange": "Channel Islands Securities Exchange",
"Line1": "Sarnia House",
"Line2": "Le Truchot",
"Line3": "St Peter Port",
"Line4": "Guernsey GY1 4NA",
"Line5": "Channel Islands",
"Country": "GBR",
"Phone": "",
"WebAddress": "http://www.glifund.com",
"NoOfEmployees": "",
"Turnover": "580000",
"TurnoverUSD": "992600.0000",
"FinancialYearEnd": "--12--",
"overView": "GLI Finance is a closed-ended investment company. It invests in senior secured loans and syndicated corporate loans issued primarily by middle market US companies. Its portfolio investment is managed by T2 Advisers. The company operates in the Channel Islands, the UK and the Cayman Islands. It is headquartered in St. Peter Port, Guernsey.|The company recorded revenues of £584.4 thousand (approximately $963.1 thousand) in the fiscal year ended December 2014. Its net loss was £13,626.4 thousand (approximately $22,457.6 thousand) in fiscal 2014.|",
"MajorProductsServices": "GLI Finance is a closed-ended investment company. The company's key activities include the following: Activities: Invests in senior secured loans and syndicated corporate loans issued primarily by middle market US companies",
"KeyEmployeesCount": "8",
"_childDocuments_": [
{
"FullName": "Geoffrey Richard Miller",
"JobTitle": "Chief Executive Officer and Executive Director",
"Board": "Executive Board"
},
{
"FullName": "Emma Stubbs",
"JobTitle": "Chief Financial Officer",
"Board": "Executive Board"
},
{
"FullName": "Patrick Anthony Seymour Firth",
"JobTitle": "Chairman",
"Board": "Non Executive Board"
},
{
"FullName": "Frederick Peter Forni",
"JobTitle": "Non-Executive Director",
"Board": "Non Executive Board"
},
{
"FullName": "James Henry Carthew",
"JobTitle": "Non-Executive Director",
"Board": "Non Executive Board"
},
{
"FullName": "Marc Krombach",
"JobTitle": "Managing Director",
"Board": "Senior Management"
},
{
"FullName": "Andrew Whelan",
"JobTitle": "Director, Lending",
"Board": "Senior Management"
},
{
"FullName": "Louise Beaumont",
"JobTitle": "Head, Public Affairs and Marketing",
"Board": "Senior Management"
}
],
"LocationsSubsidiariesCount": "5",
"Subsidiary": [
{
"SubsidiaryName": "GLIF BMS Holdings Limited",
"SubsidiaryAddressLine1": "",
"SubsidiaryAddressLine2": "",
"SubsidiaryAddressLine3": "",
"SubsidiaryAddressLine4": "",
"SubsidiaryAddressLine5": "",
"SubsidiaryAddressCountry": "GBR"
},
{
"SubsidiaryName": "Secured Loan Investments Limited",
"SubsidiaryAddressLine1": "",
"SubsidiaryAddressLine2": "",
"SubsidiaryAddressLine3": "",
"SubsidiaryAddressLine4": "",
"SubsidiaryAddressLine5": "Guernsey",
"SubsidiaryAddressCountry": "GBR"
},
{
"SubsidiaryName": "BMS Finance AB Limited",
"SubsidiaryAddressLine1": "",
"SubsidiaryAddressLine2": "",
"SubsidiaryAddressLine3": "",
"SubsidiaryAddressLine4": "",
"SubsidiaryAddressLine5": "",
"SubsidiaryAddressCountry": "GBR"
},
{
"SubsidiaryName": "NVF Tech Limited",
"SubsidiaryAddressLine1": "",
"SubsidiaryAddressLine2": "",
"SubsidiaryAddressLine3": "",
"SubsidiaryAddressLine4": "",
"SubsidiaryAddressLine5": "",
"SubsidiaryAddressCountry": "GBR"
},
{
"SubsidiaryName": "GLI Investments Holdings Sarl",
"SubsidiaryAddressLine1": "",
"SubsidiaryAddressLine2": "",
"SubsidiaryAddressLine3": "",
"SubsidiaryAddressLine4": "",
"SubsidiaryAddressLine5": "",
"SubsidiaryAddressCountry": "LUX"
}
]
}
I am getting Unknown command MLID error:
Could you please help me in creating the index?
Thanks,
Srilu

Short answer: put [] around that whole structure and it should work.
Long answer: Solr accepts JSON in 3 different forms:
Single arbitrary JSON document that Solr does smart mapping to internal fields, creating them as needed (using schemaless) approach. The request handler for that is */update/json/docs" This works, but does not support children and also maps all new fields to multiValued types.
Single arbitrary JSON document that Solr expects to be a sequence of commands, such as add, delete, and commit. This is in Solr-specific format and does support child documents. The request for that is "/update"
A multi-document shortcut of the one above, where only the documents are provided in an array, including child support.
You are hitting the use case 2 here, so Solr is complaining that the first thing it sees is NOT one of the known commands. By putting you object into the array, you switch to type 3 and it should work.
P.s. Your specific example seems to have other arrays of nested objects which will probably stop indexing (specifically "Subsidiary"). But it is a separate problem/question.

Related

Paypal API integration for debit and Credit card with Node JS

I am tiring to add credit debit card integration that are already saved in our database and I don't want user to fill those information to the paypal debit/credit card payment form.
I want to know
Is there a way to auto populate information from my database to paypal from?
Or how can I use orders API to directly pass the information to the paypal using API integration.
The Paypal really is a mess. Can anyone please help me in the integration.
NOTE : I am using React JS as front-end and nestjs as back-end.
You can't populate a form, and storing credit card information in your database is a potentially problematic practice you should review (better to tokenize/vault it) and requires a full PCI self-assessment review.
But as for how to send credit cards to PayPal via an API, if anaccount is enabled for Advanced Credit and Debit Card processing, the below might allow you to use the v2/checkout/orders API with card details in the payment_source object
(Edit: apparently more permissions are needed from PayPal for this)
{
"intent": "CAPTURE",
"payer": {
"name":{
"given_name": "John",
"surname": "Doe"
},
"email_address":"johndoe#buyersemail.com"
},
"purchase_units": [
{
"reference_id": "0000",
"description": "Transaction description",
"custom_id": "Optional arbitrary private transaction-related ID/data, 127 chars",
"soft_descriptor": "Shows On CC statement",
"amount": {
"currency_code": "USD",
"value": "100",
"breakdown": {
"item_total": {
"currency_code": "USD",
"value": "100"
},
"shipping": {
"currency_code": "USD",
"value": "0"
}
}
},
"shipping":{
"name":{
"full_name":"John Doe"
},
"address": {
"address_line_1": "123 nowhere lane ",
"address_line_2": "Unit 123",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
}
}
],
"payment_source": {
"card": {
"number": "4032038000494967",
"expiry": "2023-04",
"security_code":"123",
"name": "John Doe",
}
}
}

Defining a JSON schema with a nested array

I'm new to JSON so bear with me please (especially if I use the wrong terminology).
I'm trying to define a JSON schema with a nested array. The idea is that there could be up to 5 customers, and each customer could have up to 40 account types.
This is what I've defined, but I have a feeling it's incorrect. Could someone help me please ?
(I hope I've included enough of the relevant data to make sense)
"type":"object",
"properties":,
{
"customers":{
"description": "Contains up to 5 customers",
"type":"array",
"maxItems":5, /* Here are your 5 customers */
"minItems":0,
"items":{
"type":"object",
"properties":,
{
"customerid_cl":{
"description": "ID-KUNDNR",
"type":"integer",
"maximum":999999999,
"minimum":000000000
},
"ssn_number":{
"description": "id_persnr",
"type":"string",
"maxLength":12,
"minLength":12
},
"first_name":{
"description": "be_fnamn",
"type":"string",
"maxLength":15,
"minLength":15
},
"last_name":{
"description": "be_enamn",
"type":"string",
"maxLength":27,
"minLength":27
},
"deceased":{
"description": "FL-AVLIDEN",
"type":"boolean",
},
},
"Accounts":{
"description": "Contains up to 40 account types",
"type":"array",
"maxItems":40, /* and here are the 40 account types (potentially) for EACH customer */
"minItems":0,
"items":{
"type":"object",
"properties":,
{
"account_number":
{
"description": "id_kontonr",
"type":"string",
"maxLength":9,
"minLength":1
},
"currentbalance":
{
"description": "Current account balance - how do we indicate that negative values are okay ????",
"type": "number",
"format":"decimal",
"maximum":999999999.99,
"minimum":-999999999.99
},**strong text**

Azure Indoor Maps not rendering

Trying to create floor plan upload to azure indoor maps. It is uploaded using postman and got the tilesetid but when I provide tilesetid in the Azure Indoor maps sample, it is not rendering the image in html file. When I use sample zip file provided by azure it is working fine.
Following the article as shown in Azure Indoor Maps
Autocad settings
Below is the manifest file
{
"version": "1.1",
"directoryInfo": {
"name": "Digital Twins Testing Building",
"streetAddress": "Contoso Way",
"unit": "1",
"locality": "Eastside",
"postalCode": "00000",
"adminDivisions": [
"Contoso City",
"Contoso State",
"United States"
],
"hoursOfOperation": "Mo-Fr 08:00-17:00 open",
"phone": "1 (425) 555-1234",
"website": "www.contoso.com",
"nonPublic": false,
"anchorLatitude": 33.44277,
"anchorLongitude": -112.072754,
"anchorHeightAboveSeaLevel": 1000,
"defaultLevelVerticalExtent": 2
},
"buildingLevels": {
"levels": [{
"levelName": "Ground Level",
"ordinal": 0,
"verticalExtent": 5,
"filename": "./GroundLevelFloorPlan.dwg"
}]
},
"georeference": {
"lat": 33.44277,
"lon": -112.072754,
"angle": 0
},
"dwgLayers": {
"exterior": [
"exterior"
],
"unit": [
"unit"
]
}
}
From the manifest, I see you expressed loading only exterior and unit, and didn't pass the label layer which is what brings labels and let you add more properties for the units (or zones). If you don't see the map, I would suggest checking the conversion results (see here) which is always a good practice. Another good way to troubleshoot is review the content in the dataset via WFS API, for example units via https://atlas.microsoft.com/wfs/datasets//collections/unit/items?api-version=1.0&subscription-key={{subcriptionkey}}

How to convert Google Sheets v4 api output to a normal JavaScript Array of Objects?

I tried to find answers for this but everything seems to pertain to other things or the previous versions of the api.
I'm trying to use a google spreadsheet as a basic json backend. My spreadsheets looks something like this:
Google sheets api v4 has a method called batchGet. The call (https://sheets.googleapis.com/v4/spreadsheets/1kEhCvvbHt-9BZgKKp-eQsy7l0AkFtZ9_7cIhvyVGLZ8/values:batchGet?ranges=data&majorDimension=ROWS) outputs my spreadsheet to be something like this:
{
"spreadsheetId": "1kEhCvvbHt-9BZgKKp-eQsy7l0AkFtZ9_7cIhvyVGLZ8",
"valueRanges": [
{
"range": "data!A1:O1000",
"majorDimension": "ROWS",
"values": [
[
"id",
"name",
"location",
"Description",
"website",
"image",
"Address",
"lat",
"lng",
"color",
"Products",
"Cartridges",
"High-CBD Tincture",
"THCa Crystalline"
],
[
"1",
"Erba",
"West Los Angeles",
"Erba’s philosophy is to carry only the most top-tier products, and never sacrifice quality by all means necessary. You’ll feel the difference once you step foot inside their impressive shop.",
"http://erbacollective.com/",
"https://static.wixstatic.com/media/e4d816_49fd88e6e519486b8be81fd955a52b35~mv2.png/v1/fill/w_173,h_173,al_c,usm_0.66_1.00_0.01/e4d816_49fd88e6e519486b8be81fd955a52b35~mv2.png",
"12320 W Pico Blvd, Los Angeles, CA 90064\n",
"34.028126",
"-118.452295",
"#7CB711",
"Full-spectrum vape carts, THCa crystalline and tincture.",
"TRUE",
"FALSE",
"TRUE"
],
[
"2",
"99 High Tide",
"Malibu",
"99 High Tide is Malibu's only medical marijuana dispensary. They are a visionary collective of Cannabis experts, artists, DJs, growers, healers & shamans.",
"http://99hightide.com/",
"https://static.wixstatic.com/media/e4d816_a576375fe1104c1399cc0249b7c3818e~mv2.png/v1/fill/w_173,h_173,al_c,usm_0.66_1.00_0.01/e4d816_a576375fe1104c1399cc0249b7c3818e~mv2.png",
"22775 Pacific Coast Hwy, Malibu, CA 90265\n",
"34.039466",
"-118.671939",
"#3A8ABD",
"Full-spectrum vape carts and THCa crystalline.",
"TRUE",
"FALSE",
"TRUE"
],
[
What I need is something like this (in order for it to play nicely in React):
"rows": [
{
"id": 1,
"name": "Erba",
"location": "West Los Angeles",
"description": "Erba’s philosophy is to carry only the most top-tier products, and never sacrifice quality by all means necessary. You’ll feel the difference once you step foot inside their impressive shop.",
"website": "http://erbacollective.com/",
"image": "https://static.wixstatic.com/media/e4d816_49fd88e6e519486b8be81fd955a52b35~mv2.png/v1/fill/w_173,h_173,al_c,usm_0.66_1.00_0.01/e4d816_49fd88e6e519486b8be81fd955a52b35~mv2.png",
"address": "12320 W Pico Blvd, Los Angeles, CA 90064\n",
"lat": 34.028126,
"lng": -118.452295,
"color": "#7CB711",
"products": "Full-spectrum vape carts, THCa crystalline and tincture.",
"cartridges": "TRUE",
"high-cbdtincture": "FALSE",
"thcacrystalline": "TRUE"
},
{
"id": 2,
"name": "99 High Tide",
"location": "Malibu",
"description": "99 High Tide is Malibu's only medical marijuana dispensary. They are a visionary collective of Cannabis experts, artists, DJs, growers, healers & shamans.",
"website": "http://99hightide.com/",
"image": "https://static.wixstatic.com/media/e4d816_a576375fe1104c1399cc0249b7c3818e~mv2.png/v1/fill/w_173,h_173,al_c,usm_0.66_1.00_0.01/e4d816_a576375fe1104c1399cc0249b7c3818e~mv2.png",
"address": "22775 Pacific Coast Hwy, Malibu, CA 90265\n",
"lat": 34.039466,
"lng": -118.671939,
"color": "#3A8ABD",
"products": "Full-spectrum vape carts and THCa crystalline.",
"cartridges": "TRUE",
"high-cbdtincture": "FALSE",
"thcacrystalline": "TRUE"
},
{
"id": 3,
"name": "The Higher Path",
"location": "Sherman Oaks",
"description": "Named the Best Dispensary in Los Angeles 2016, The Higher Path Collective serves both medical patients and adult use recreational consumers! Hailing from Northern California, The Higher Path’s owner Jerred Kiloh brings a very different mentality of medicine with him to Southern California—one that puts the patient before everything else. Since opening in 2013, it’s been The Higher Path’s focus and passion to help provide patients with the knowledge and medicine they need.",
"website": "https://www.thehigherpath.com/",
"image": "https://static.wixstatic.com/media/e4d816_8304a48460884d9ea5cac420164fe9cb~mv2.png/v1/fill/w_173,h_173,al_c,usm_0.66_1.00_0.01/e4d816_8304a48460884d9ea5cac420164fe9cb~mv2.png",
"address": "14080 Ventura Blvd, Sherman Oaks, CA 91423\n",
"lat": 34.149202,
"lng": -118.439813,
"color": "#9050A4",
"products": "Full-spectrum vape carts.",
"cartridges": "TRUE",
"high-cbdtincture": "FALSE",
"thcacrystalline": "FALSE"
},
{
"id": 4,
"name": "Sespe Creek",
"location": "Ojai",
"description": "Sespe aims to bring the best of our local region’s strains, concentrates, drinks, edibles and topicals to patients with all budgets, health backgrounds and tastes.",
"website": "http://sespe.org/",
"image": "https://static.wixstatic.com/media/e4d816_5fe69dd77579484a8980aeffc8beacb3~mv2.png/v1/fill/w_173,h_173,al_c,usm_0.66_1.00_0.01/e4d816_5fe69dd77579484a8980aeffc8beacb3~mv2.png",
"address": "408 Bryant Cir Unit C, Ojai, CA 93023\n",
"lat": 34.443072,
"lng": -119.237926,
"color": "#DC3267",
"products": "Entire lineup of full-spectrum extracts.",
"cartridges": "FALSE",
"high-cbdtincture": "FALSE",
"thcacrystalline": "FALSE"
},
How do I convert the output data into a nice json array of objects?
You need to loop through the output and create your own Object.
function makeObject() {
var batchResponse; // This is the response from batchGet()
batchResponse = "{\"spreadsheetId\": \"1kEhCvvbHt-9BZgKKp-eQsy7l0AkFtZ9_7cIhvyVGLZ8\",\"valueRanges\": [{\"range\": \"data!A1:O1000\",\"majorDimension\": \"ROWS\",\"values\": [[\"id\",\"name\",\"location\",\"Description\",\"website\",\"image\",\"Address\",\"lat\",\"lng\",\"color\",\"Products\",\"Cartridges\",\"High-CBD Tincture\",\"THCa Crystalline\"],[\"1\",\"Erba\",\"West Los Angeles\",\"Erba’s philosophy is to carry only the most top-tier products, and never sacrifice quality by all means necessary. You’ll feel the difference once you step foot inside their impressive shop.\",\"http:\/\/erbacollective.com\/\",\"https:\/\/static.wixstatic.com\/media\/e4d816_49fd88e6e519486b8be81fd955a52b35~mv2.png\/v1\/fill\/w_173,h_173,al_c,usm_0.66_1.00_0.01\/e4d816_49fd88e6e519486b8be81fd955a52b35~mv2.png\",\"12320 W Pico Blvd, Los Angeles, CA 90064\\n\",\"34.028126\",\"-118.452295\",\"#7CB711\",\"Full-spectrum vape carts, THCa crystalline and tincture.\",\"TRUE\",\"FALSE\",\"TRUE\"],[\"2\",\"99 High Tide\",\"Malibu\",\"99 High Tide is Malibu's only medical marijuana dispensary. They are a visionary collective of Cannabis experts, artists, DJs, growers, healers & shamans.\",\"http:\/\/99hightide.com\/\",\"https:\/\/static.wixstatic.com\/media\/e4d816_a576375fe1104c1399cc0249b7c3818e~mv2.png\/v1\/fill\/w_173,h_173,al_c,usm_0.66_1.00_0.01\/e4d816_a576375fe1104c1399cc0249b7c3818e~mv2.png\",\"22775 Pacific Coast Hwy, Malibu, CA 90265\\n\",\"34.039466\",\"-118.671939\",\"#3A8ABD\",\"Full-spectrum vape carts and THCa crystalline.\",\"TRUE\",\"FALSE\",\"TRUE\"]]}]\n}";
batchResponse = JSON.parse(batchResponse); // Convert from JSON to Object
var batchRowValues = batchResponse["valueRanges"][0]["values"];
var rows = [];
for (var i=1; i<batchRowValues.length; i++) {
var rowObject = {};
for (var j=0; j<batchRowValues[i].length; j++) {
rowObject[batchRowValues[0][j]] = batchRowValues[i][j];
}
rows.push(rowObject);
}
return rows;
}
Note:
I hard-coded the example JSON output from batchGet() you provided
This function returns an Array. If you want it to return JSON, then the final line should read return JSON.stringify(rows);.

trying to parse JSON data with Angular 1 Controller. getting error: "bad control character in string literal at line 7 column 131 of the JSON data"

I'm trying to grab brad pitt's movie titles from this JSON data, but I keep getting the error:
"trying to parse JSON data. getting error "bad control character in string literal at line 7 column 131 of the JSON data"
Here's my Angular 1 Controller:
angular.module('superActorQuiz.question', [])
.controller('questionController', function ($scope, $http, $window) {
console.log('in questionController')
$scope.movie;
$http.get("themoviedb_data.json")
.then(function (response) {
console.log('results',response.data);
$scope.games = response.data.results[0].title.map(function(item) {
console.log(item)
return item;
});
})
})
And here's the first part of the JSON data of brad pitt's movies. Line 7 would be where the overview starts for the movie Fury. I've tried my controller code, the http.get, with other json objects and it works. Any ideas on why I'm getting that error with this Json data?
{
"page": 1,
"results":
[{
"poster_path": "\/il9XWx5CbNd2KdDUwrcClEZiLkv.jpg",
"adult": false,
"overview": "Last months of World War II in April 1945. As the Allies make their final push in the European Theater,
a battle-hardened U.S. Army sergeant in the 2nd Armored Division named Wardaddy commands a Sherman tank called \"Fury\" and its five-man crew on a deadly mission behind enemy lines. Outnumbered and outgunned,
Wardaddy and his men face overwhelming odds in their heroic attempts to strike at the heart of Nazi Germany.",
"release_date": "2014-10-15",
"genre_ids": [10752,
18,
28],
"id": 228150,
"original_title": "Fury",
"original_language": "en",
"title": "Fury",
"backdrop_path": "\/pKawqrtCBMmxarft7o1LbEynys7.jpg",
"popularity": 11.717304,
"vote_count": 2435,
"video": false,
"vote_average": 7.43
}, {
"poster_path": "\/adw6Lq9FiC9zjYEpOqfq03ituwp.jpg",
"adult": false,
"overview": "A ticking-time-bomb insomniac and a slippery soap salesman channel primal male aggression into a shocking new form of therapy. Their concept catches on,
with underground \"fight clubs\" forming in every town,
until an eccentric gets in the way and ignites an out-of-control spiral toward oblivion.",
"release_date": "1999-10-14",
"genre_ids": [18],
"id": 550,
"original_title": "Fight Club",
"original_language": "en",
"title": "Fight Club",
"backdrop_path": "\/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg",
"popularity": 7.681482,
"vote_count": 5581,
"video": false,
"vote_average": 8.07
}, {
"poster_path": "\/p11Ftd4VposrAzthkhF53ifYZRl.jpg",
"adult": false,
"overview": "The men who made millions from a global economic meltdown.",
"release_date": "2015-12-11",
"genre_ids": [18,
35],
"id": 318846,
"original_title": "The Big Short",
"original_language": "en",
"title": "The Big Short",
"backdrop_path": "\/jmlMLYEsYY1kRc5qHIyTdxCeVmZ.jpg",
"popularity": 6.207392,
"vote_count": 1395,
"video": false,
"vote_average": 7.26
}]}
Thanks so much!

Resources