Binding Data to Kendo ui Scheduler - kendo-ui

I've managed to get the Kendo UI scheduler to work as far as adding resources creating new events and saving new events. However I'm unable to get data from an asp.net web api and display it. Can someone provide an example of how to bind it to the following data:
[{"Client":{"ID":1,"Name":"Ford Motor Company","IsActive":true,"DisplayColor":null},"ID":7,"StartDateTime":"2014-04-14T11:00:00","EndDateTime":"2014-04-14T11:30:00","Title":"sdfsdf","Description":"","IsAllDay":false,"Resources":[{"Name":"Eric Longsdorf","ID":1,"IsActive":true,"PhoneNumber":null}],"EquipmentItems":[{"ID":1,"Description":"Truck # 1","IsActive":true,"Status":1}]},{"Client":{"ID":1,"Name":"Ford Motor Company","IsActive":true,"DisplayColor":null},"ID":8,"StartDateTime":"2014-04-14T11:00:00","EndDateTime":"2014-04-14T11:30:00","Title":"Test","Description":"Thee","IsAllDay":false,"Resources":[{"Name":"Eric Longsdorf","ID":1,"IsActive":true,"PhoneNumber":null}],"EquipmentItems":[{"ID":1,"Description":"Truck # 1","IsActive":true,"Status":1}]},{"Client":{"ID":1,"Name":"Ford Motor Company","IsActive":true,"DisplayColor":null},"ID":9,"StartDateTime":"2014-04-14T11:00:00","EndDateTime":"2014-04-14T11:30:00","Title":"yrtyr","Description":"dfg","IsAllDay":false,"Resources":[{"Name":"Eric Longsdorf","ID":1,"IsActive":true,"PhoneNumber":null},{"Name":"Jim Smith","ID":3,"IsActive":true,"PhoneNumber":null}],"EquipmentItems":[{"ID":1,"Description":"Truck # 1","IsActive":true,"Status":1},{"ID":3,"Description":"Vacuum 26","IsActive":true,"Status":1}]},{"Client":{"ID":1,"Name":"Ford Motor Company","IsActive":true,"DisplayColor":null},"ID":10,"StartDateTime":"2014-04-14T11:00:00","EndDateTime":"2014-04-14T11:30:00","Title":"","Description":"","IsAllDay":false,"Resources":[{"Name":"Eric Longsdorf","ID":1,"IsActive":true,"PhoneNumber":null}],"EquipmentItems":[{"ID":1,"Description":"Truck # 1","IsActive":true,"Status":1},{"ID":2,"Description":"Truck # 2","IsActive":true,"Status":3}]},{"Client":{"ID":1,"Name":"Ford Motor Company","IsActive":true,"DisplayColor":null},"ID":11,"StartDateTime":"2014-04-14T11:30:00","EndDateTime":"2014-04-14T12:00:00","Title":"fgdfg","Description":"dfg","IsAllDay":false,"Resources":[{"Name":"Eric Longsdorf","ID":1,"IsActive":true,"PhoneNumber":null}],"EquipmentItems":[{"ID":2,"Description":"Truck # 2","IsActive":true,"Status":3},{"ID":1,"Description":"Truck # 1","IsActive":true,"Status":1}]},{"Client":{"ID":1,"Name":"Ford Motor Company","IsActive":true,"DisplayColor":null},"ID":1008,"StartDateTime":"2014-04-14T11:00:00","EndDateTime":"2014-04-14T11:30:00","Title":"sdfsd","Description":"sdf","IsAllDay":false,"Resources":[{"Name":"Eric Longsdorf","ID":1,"IsActive":true,"PhoneNumber":null}],"EquipmentItems":[{"ID":1,"Description":"Truck # 1","IsActive":true,"Status":1},{"ID":2,"Description":"Truck # 2","IsActive":true,"Status":3}]},{"Client":{"ID":1,"Name":"Ford Motor Company","IsActive":true,"DisplayColor":null},"ID":1009,"StartDateTime":"2014-04-14T11:00:00","EndDateTime":"2014-04-14T11:30:00","Title":"sdfsd","Description":"sdf","IsAllDay":false,"Resources":[{"Name":"Eric Longsdorf","ID":1,"IsActive":true,"PhoneNumber":null}],"EquipmentItems":[{"ID":2,"Description":"Truck # 2","IsActive":true,"Status":3},{"ID":1,"Description":"Truck # 1","IsActive":true,"Status":1}]}]

Please try with the below code snippet.
<div id="scheduler">
</div>
<script>
var test = '[{ "Client": { "ID": 1, "Name": "Ford Motor Company", "IsActive": true, "DisplayColor": null }, "ID": 7, "StartDateTime": "2014-04-15T11:00:00", "EndDateTime": "2014-04-15T11:30:00", "Title": "First Meeting", "Description": "", "IsAllDay": false, "Resources": [{ "Name": "Eric Longsdorf", "ID": 1, "IsActive": true, "PhoneNumber": null}], "EquipmentItems": [{ "ID": 1, "Description": "Truck # 1", "IsActive": true, "Status": 1}] }, { "Client": { "ID": 1, "Name": "Ford Motor Company", "IsActive": true, "DisplayColor": null }, "ID": 8, "StartDateTime": "2014-04-14T11:00:00", "EndDateTime": "2014-04-14T11:30:00", "Title": "Test", "Description": "Thee", "IsAllDay": false, "Resources": [{ "Name": "Eric Longsdorf", "ID": 1, "IsActive": true, "PhoneNumber": null}], "EquipmentItems": [{ "ID": 1, "Description": "Truck # 1", "IsActive": true, "Status": 1}] }, { "Client": { "ID": 1, "Name": "Ford Motor Company", "IsActive": true, "DisplayColor": null }, "ID": 9, "StartDateTime": "2014-04-14T11:00:00", "EndDateTime": "2014-04-14T11:30:00", "Title": "yrtyr", "Description": "dfg", "IsAllDay": false, "Resources": [{ "Name": "Eric Longsdorf", "ID": 1, "IsActive": true, "PhoneNumber": null }, { "Name": "Jim Smith", "ID": 3, "IsActive": true, "PhoneNumber": null}], "EquipmentItems": [{ "ID": 1, "Description": "Truck # 1", "IsActive": true, "Status": 1 }, { "ID": 3, "Description": "Vacuum 26", "IsActive": true, "Status": 1}] }, { "Client": { "ID": 1, "Name": "Ford Motor Company", "IsActive": true, "DisplayColor": null }, "ID": 10, "StartDateTime": "2014-04-14T11:00:00", "EndDateTime": "2014-04-14T11:30:00", "Title": "", "Description": "", "IsAllDay": false, "Resources": [{ "Name": "Eric Longsdorf", "ID": 1, "IsActive": true, "PhoneNumber": null}], "EquipmentItems": [{ "ID": 1, "Description": "Truck # 1", "IsActive": true, "Status": 1 }, { "ID": 2, "Description": "Truck # 2", "IsActive": true, "Status": 3}] }, { "Client": { "ID": 1, "Name": "Ford Motor Company", "IsActive": true, "DisplayColor": null }, "ID": 11, "StartDateTime": "2014-04-14T11:30:00", "EndDateTime": "2014-04-14T12:00:00", "Title": "fgdfg", "Description": "dfg", "IsAllDay": false, "Resources": [{ "Name": "Eric Longsdorf", "ID": 1, "IsActive": true, "PhoneNumber": null}], "EquipmentItems": [{ "ID": 2, "Description": "Truck # 2", "IsActive": true, "Status": 3 }, { "ID": 1, "Description": "Truck # 1", "IsActive": true, "Status": 1}] }, { "Client": { "ID": 1, "Name": "Ford Motor Company", "IsActive": true, "DisplayColor": null }, "ID": 1008, "StartDateTime": "2014-04-14T11:00:00", "EndDateTime": "2014-04-14T11:30:00", "Title": "sdfsd", "Description": "sdf", "IsAllDay": false, "Resources": [{ "Name": "Eric Longsdorf", "ID": 1, "IsActive": true, "PhoneNumber": null}], "EquipmentItems": [{ "ID": 1, "Description": "Truck # 1", "IsActive": true, "Status": 1 }, { "ID": 2, "Description": "Truck # 2", "IsActive": true, "Status": 3}] }, { "Client": { "ID": 1, "Name": "Ford Motor Company", "IsActive": true, "DisplayColor": null }, "ID": 1009, "StartDateTime": "2014-04-14T11:00:00", "EndDateTime": "2014-04-14T11:30:00", "Title": "sdfsd", "Description": "sdf", "IsAllDay": false, "Resources": [{ "Name": "Eric Longsdorf", "ID": 1, "IsActive": true, "PhoneNumber": null}], "EquipmentItems": [{ "ID": 2, "Description": "Truck # 2", "IsActive": true, "Status": 3 }, { "ID": 1, "Description": "Truck # 1", "IsActive": true, "Status": 1}]}]';
$(function () {
$("#scheduler").kendoScheduler({
height: 600,
views: [
"day",
{ type: "workWeek", selected: true },
"week",
"month",
"agenda"
],
timezone: "Etc/UTC",
dataSource: {
data: eval(test),
schema: {
model: {
id: "ID",
fields: {
taskId: { from: "ID", type: "number" },
title: { from: "Title" },
start: { type: "date", from: "StartDateTime" },
end: { type: "date", from: "EndDateTime" },
//startTimezone: { from: "StartTimezone" },
//endTimezone: { from: "EndTimezone" },
description: { from: "Description" },
//recurrenceId: { from: "RecurrenceID" },
//recurrenceRule: { from: "RecurrenceRule" },
//recurrenceException: { from: "RecurrenceException" },
//ownerId: { from: "OwnerID", defaultValue: 1 },
isAllDay: { type: "boolean", from: "IsAllDay" }
}
}
}
}
});
});
</script>
Demo
Let me know if any concern.

Related

two node Elasticsearch cluster having data sync issue

I have a 2 node Elasticsearch cluster with both as master eligible nodes. They both are formed a cluster and named as **node1 and **node2. Couple of weeks back we have upgraded the version of ES from 7.9 to 7.17.4. Now there was an issue reported that there is some data sync issue between the nodes.
When hitting elasticsearch url we are seeing different data for an index. so we tried to hit two node urls individually as below and we observed different data on each node.
curl http://node1:9200/vehicle/_search?q=***
curl http://node2:9200/vehicle/_search?q=***
I know that data on a cluster will get synced automatically on elasticsearch but I think this is not happening in my case. Could you please let me know why this is happening ? is there anything that I can forcefully sync data between nodes.
What could be the reason to get different data on the nodes ? what should I check why there is a different data getting populated ?
Here are the curl queries and their results on two nodes. Node 2 has an additional object along with the first object with a small difference in the last line.
curl http://node1:9200/vehicle/_search?q=XYZ
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 7.8380795,
"hits": [
{
"_index": "vehicle_inventory",
"_type": "_doc",
"_id": "109802",
"_score": 7.8380795,
"_source": {
"abs": "Yes",
"addressLine1": "965 ALDRIN DR",
"addressLine2": " ",
"aeroCabExtenders": "Yes",
"aeroRoof": " ",
"aeroSideFairings": "Yes",
"airConditioning": "Yes",
"areaName": " ",
"areaNumber": "0617",
"bodyMake": "NULL",
"bodySerialNumber": "NULL",
"bodyFloorType": "",
"bodyRoofType": "",
"brakeType": "NULL",
"cabStyle": "Conventional",
"category": "TRACTOR",
"chassisBumper": "AERO",
"chassisMakeCode": "FTL",
"cdlRequired": "Yes",
"city": "Eagan",
"color": "White",
"modified_color": "WHITE",
"compared": false,
"saved": false,
"country": "US",
"countryExt": "United States",
"collisionWarning": "No",
"collisionWarningModel": "",
"customerNumber": "RENTAL",
"description": "AVAILABLE JANUARY 2022",
"displayDeliveryCal": "Y",
"districtName": " ",
"driverSeatType": "AIR",
"emailAddress": "E-MAIL.GENERAL.LOCATION#XXXXXX",
"engineBrake": "Yes",
"engineMake": "Detroit",
"engineModel4": "DD15AT",
"engineHours": 0,
"faxNumber": "06516860476",
"featuredListing": "Y",
"frontAxleCapacity": "13300",
"frontWheelType": "",
"fuelType": "DIESEL",
"grossVehicleWeight": 80000,
"height": "NULL",
"horsepower": 455,
"image": "/usedtrucks/image/109802/1",
"interiorLevel": "PREMIUM",
"individualPageUrl": "",
"liftGate": "NULL",
"liftGateCapacity": "0",
"liftGateModel": " ",
"loadLength": "NULL",
"make": "Freightliner",
"managersSpecial": "false",
"managerSpecialDiscountRetail": "0",
"managerSpecialDiscountWholeSale": "0",
"mileage": "701,830 miles",
"model": "Cascadia 12564ST",
"newListing": "false",
"numberOfBunks": "2",
"numberOfDriveAxles": "2",
"numberOfTanks": "Dual",
"numericHeight": "",
"numericLoadLength": -1,
"numericWidth": "",
"offLease": "N",
"originalWholeSalePrice": "64,500",
"originalRetailPrice": "64,500",
"phoneNumber": "1-866-309-1962",
"promotionVehicle": "true",
"rearAxleCapacity": "40000",
"rearAxleMake": "Detroit",
"rearDoor": "NULL",
"rearRatio": "2.53",
"rearWheelType": "",
"reeferStandby": "",
"refrigerationHours": "",
"refrigerationMake": "NULL",
"refrigerationModel": "NULL",
"retailPrice": "54,500",
"salePutUpDate": "2021-12-17 00:00:00",
"sideConstruction": "NULL",
"sideDoor": "NULL",
"sleeperSize": "72",
"sleeperType": "Raised Roof",
"slidingFifthWheel": "Yes",
"state": "MN",
"status": "ACTIVE",
"statusComments": " ",
"sale_reason_desc": "AVAILABLE JANUARY 2022",
"saleType": " ",
"size": "",
"suspension": "Air",
"tareWeight": "18795",
"thumbnail": "usedtrucks/image/109802t/1",
"tireSize": "11R22.5",
"tireType": "S/WAY",
"totalFuelCapacity": "220",
"transmissionMake": "Detroit",
"transmissionModel": "12DA1550",
"transmissionSpeed": "12",
"transmissionType": "Automatic",
"type": "Sleeper Tractor",
"unitNumber": "109802",
"use": "RENTAL",
"vin": "3AKJGLD53FSGJ8668",
"wheelBase": "228\"",
"wheelType": "Aluminum",
"wholesalePrice": "59,500",
"width": "NULL",
"year": 2015,
"zip": "55121",
"numeric_mileage": 701830,
"numeric_retail_price": 54500,
"numeric_wholesale_price": 59500,
"dLatitude": 44.944400787353516,
"dLongitude": -93.09329986572266,
"bodyModel": null,
"promotionAmount": "10,000",
"salePrice": 0,
"location": "016510",
"jpegImage": "/usedtrucks/JpgServlet/109802_1.jpg",
"translatedCategory": "Heavy Duty Tractors",
"originalCategory": "Heavy Duty Tractors",
"monFriHours": "M-F 8:00 am to 8:00 pm ET",
"satHours": "Sat 9:00 am to 3:00 pm ET",
"mobileSitePhone": "1-800-485-9671",
"salePutUpDatesort": "2021-12-17",
"stringyear": "2015",
"range_grossVehicleWeight": null,
"range_loadLength": null,
"range_horsepower": "401 and more",
"range_cabType": "Raised Roof",
"range_retailCenter": null,
"viewCount": "222ST15",
"advertTerm": "Level 1",
"numeric_Height": 0,
"numeric_totalFuelCapacity": 0,
"numeric_Width": 0,
"promotionList": [
{
"name": "Save on Select Sleeper Tractors",
"description": "Save on Select Sleeper Tractors",
"amount": 10000,
"amountDisplayRetail": "10,000",
"amountDisplayWholeSale": "10,000",
"type": "DISCOUNT",
"rule": "viewCount != null and viewCount.equalsIgnoreCase('222ST15') and (year <= 2014 or numeric_mileage >= 700)"
}
],
"imageMaxInstance": 10,
"defaultImageBeanList": null,
"translationsMap": {
"cdlRequired": "Yes",
"countryExt": "United States",
"advertTerm": "Level 1",
"color": "White",
"range_horsepower": "401 and more",
"range_cabType": "Raised Roof",
"model": "Cascadia 12564ST",
"category": "Heavy Duty Tractors",
"type": "Sleeper Tractor"
},
"vehicle_suggestions": {},
"vehicle_locations": {
"lon": "-93.0933",
"lat": "44.9444"
},
"combo_filter": [
{
"filter_name": "range_horsepower",
"filter_value": "401 and more"
},
{
"filter_name": "range_cabType",
"filter_value": "Raised Roof"
},
{
"filter_name": "range_retailCenter",
"filter_value": null
},
{
"filter_name": "advertTerm",
"filter_value": "Level 1"
},
{
"filter_name": "airConditioning",
"filter_value": "Yes"
},
{
"filter_name": "category",
"filter_value": "Heavy Duty Tractors"
},
{
"filter_name": "color",
"filter_value": "White"
},
{
"filter_name": "engineMake",
"filter_value": "Detroit"
},
{
"filter_name": "fuelType",
"filter_value": "DIESEL"
},
{
"filter_name": "make",
"filter_value": "Freightliner"
},
{
"filter_name": "model",
"filter_value": "Cascadia 12564ST"
},
{
"filter_name": "newListing",
"filter_value": "false"
},
{
"filter_name": "numberOfBunks",
"filter_value": "2"
},
{
"filter_name": "numberOfDriveAxles",
"filter_value": "2"
},
{
"filter_name": "state",
"filter_value": "MN"
},
{
"filter_name": "transmissionMake",
"filter_value": "Detroit"
},
{
"filter_name": "transmissionSpeed",
"filter_value": "12"
},
{
"filter_name": "transmissionType",
"filter_value": "Automatic"
},
{
"filter_name": "type",
"filter_value": "Sleeper Tractor"
},
{
"filter_name": "collisionWarning",
"filter_value": "No"
},
{
"filter_name": "canada",
"filter_value": null
},
{
"filter_name": "unitedStates",
"filter_value": "MN"
},
{
"filter_name": "countryExt",
"filter_value": "United States"
},
{
"filter_name": "promotionVehicle",
"filter_value": "true"
},
{
"filter_name": "promotions",
"filter_value": "Current Deals"
},
{
"filter_name": "promotions",
"filter_value": "Save on Select Sleeper Tractors"
}
],
"slider_filter_integer": [
{
"filter_name": "numeric_mileage",
"filter_value": 701830
},
{
"filter_name": "year",
"filter_value": 2015
}
],
"slider_filter_float": [
{
"filter_name": "numeric_retail_price",
"filter_value": 54500
},
{
"filter_name": "numeric_wholesale_price",
"filter_value": 59500
}
],
"basic_filter": {},
"rowNum": 2465,
"displayManagerspecial": null,
"displayPromotions": "true",
"canada": null,
"unitedStates": "MN",
"mgrSpecialRetail": "false",
"mgrSpecialWholesale": "false",
"promotions": []
}
}
]
}
}
curl http://node2:9200/vehicle/_search?q=XYZ
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 7.8380795,
"hits": [
{
"_index": "vehicle_inventory",
"_type": "_doc",
"_id": "109802",
"_score": 7.8380795,
"_source": {
"abs": "Yes",
"addressLine1": "965 ALDRIN DR",
"addressLine2": " ",
"aeroCabExtenders": "Yes",
"aeroRoof": " ",
"aeroSideFairings": "Yes",
"airConditioning": "Yes",
"areaName": " ",
"areaNumber": "0617",
"bodyMake": "NULL",
"bodySerialNumber": "NULL",
"bodyFloorType": "",
"bodyRoofType": "",
"brakeType": "NULL",
"cabStyle": "Conventional",
"category": "TRACTOR",
"chassisBumper": "AERO",
"chassisMakeCode": "FTL",
"cdlRequired": "Yes",
"city": "Eagan",
"color": "White",
"modified_color": "WHITE",
"compared": false,
"saved": false,
"country": "US",
"countryExt": "United States",
"collisionWarning": "No",
"collisionWarningModel": "",
"customerNumber": "RENTAL",
"description": "AVAILABLE JANUARY 2022",
"displayDeliveryCal": "Y",
"districtName": " ",
"driverSeatType": "AIR",
"emailAddress": "E-MAIL.GENERAL.LOCATION#XXXXXX",
"engineBrake": "Yes",
"engineMake": "Detroit",
"engineModel": "DD15AT",
"engineHours": 0,
"faxNumber": "06516860476",
"featuredListing": "Y",
"frontAxleCapacity": "13300",
"frontWheelType": "",
"fuelType": "DIESEL",
"grossVehicleWeight": 80000,
"height": "NULL",
"horsepower": 455,
"image": "/usedtrucks/image/109802/1",
"interiorLevel": "PREMIUM",
"individualPageUrl": "",
"liftGate": "NULL",
"liftGateCapacity": "0",
"liftGateModel": " ",
"loadLength": "NULL",
"make": "Freightliner",
"managersSpecial": "false",
"managerSpecialDiscountRetail": "0",
"managerSpecialDiscountWholeSale": "0",
"mileage": "701,830 miles",
"model": "Cascadia 12564ST",
"newListing": "false",
"numberOfBunks": "2",
"numberOfDriveAxles": "2",
"numberOfTanks": "Dual",
"numericHeight": "",
"numericLoadLength": -1,
"numericWidth": "",
"offLease": "N",
"originalWholeSalePrice": "64,500",
"originalRetailPrice": "64,500",
"phoneNumber": "1-866-309-1962",
"promotionVehicle": "true",
"rearAxleCapacity": "40000",
"rearAxleMake": "Detroit",
"rearDoor": "NULL",
"rearRatio": "2.53",
"rearWheelType": "",
"reeferStandby": "",
"refrigerationHours": "",
"refrigerationMake": "NULL",
"refrigerationModel": "NULL",
"retailPrice": "44,500",
"salePutUpDate": "2021-12-17 00:00:00",
"sideConstruction": "NULL",
"sideDoor": "NULL",
"sleeperSize": "72",
"sleeperType": "Raised Roof",
"slidingFifthWheel": "Yes",
"state": "MN",
"status": "ACTIVE",
"statusComments": " ",
"sale_reason_desc": "AVAILABLE JANUARY 2022",
"saleType": " ",
"size": "",
"suspension": "Air",
"tareWeight": "18795",
"thumbnail": "usedtrucks/image/109802t/1",
"tireSize": "11R22.5",
"tireType": "S/WAY",
"totalFuelCapacity": "220",
"transmissionMake": "Detroit",
"transmissionModel": "12DA1550",
"transmissionSpeed": "12",
"transmissionType": "Automatic",
"type": "Sleeper Tractor",
"unitNumber": "109802",
"use": "RENTAL",
"vin": "3AKJGLD53FSGJ8668",
"wheelBase": "228\"",
"wheelType": "Aluminum",
"wholesalePrice": "59,500",
"width": "NULL",
"year": 2015,
"zip": "55121",
"numeric_mileage": 701830,
"numeric_retail_price": 44500,
"numeric_wholesale_price": 59500,
"dLatitude": 44.944400787353516,
"dLongitude": -93.09329986572266,
"bodyModel": null,
"promotionAmount": "10,000",
"salePrice": 0,
"location": "016510",
"jpegImage": "/usedtrucks/JpgServlet/109802_1.jpg",
"translatedCategory": "Heavy Duty Tractors",
"originalCategory": "Heavy Duty Tractors",
"monFriHours": "M-F 8:00 am to 8:00 pm ET",
"satHours": "Sat 9:00 am to 3:00 pm ET",
"mobileSitePhone": "1-800-485-9671",
"salePutUpDatesort": "2021-12-17",
"stringyear": "2015",
"range_grossVehicleWeight": null,
"range_loadLength": null,
"range_horsepower": "401 and more",
"range_cabType": "Raised Roof",
"range_retailCenter": null,
"viewCount": "222ST15",
"advertTerm": "Level 1",
"numeric_Height": 0,
"numeric_totalFuelCapacity": 0,
"numeric_Width": 0,
"promotionList": [
{
"name": "Save on Select Sleeper Tractors",
"description": "Save on Select Sleeper Tractors",
"amount": 10000,
"amountDisplayRetail": "10,000",
"amountDisplayWholeSale": "10,000",
"type": "DISCOUNT",
"rule": "viewCount != null and viewCount.equalsIgnoreCase('222ST15') and (numeric_mileage < 700 or year > 2014)"
},
{
"name": "Save on Select Sleeper Tractors. Save an additional $5,000 when financing with Premier Financing",
"description": "Save on Select Sleeper Tractors. Save an additional $5,000 when financing with Premier Financing",
"amount": 10000,
"amountDisplayRetail": "10,000",
"amountDisplayWholeSale": "10,000",
"type": "DISCOUNT",
"rule": "viewCount != null and viewCount.equalsIgnoreCase('222ST15') and (numeric_mileage >= 700 or year <= 2014) "
}
],
"imageMaxInstance": 10,
"defaultImageBeanList": null,
"translationsMap": {
"cdlRequired": "Yes",
"countryExt": "United States",
"advertTerm": "Level 1",
"color": "White",
"range_horsepower": "401 and more",
"range_cabType": "Raised Roof",
"model": "Cascadia 12564ST",
"category": "Heavy Duty Tractors",
"type": "Sleeper Tractor"
},
"vehicle_suggestions": {},
"vehicle_locations": {
"lon": "-93.0933",
"lat": "44.9444"
},
"combo_filter": [
{
"filter_name": "range_horsepower",
"filter_value": "401 and more"
},
{
"filter_name": "range_cabType",
"filter_value": "Raised Roof"
},
{
"filter_name": "range_retailCenter",
"filter_value": null
},
{
"filter_name": "advertTerm",
"filter_value": "Level 1"
},
{
"filter_name": "airConditioning",
"filter_value": "Yes"
},
{
"filter_name": "category",
"filter_value": "Heavy Duty Tractors"
},
{
"filter_name": "color",
"filter_value": "White"
},
{
"filter_name": "engineMake",
"filter_value": "Detroit"
},
{
"filter_name": "fuelType",
"filter_value": "DIESEL"
},
{
"filter_name": "make",
"filter_value": "Freightliner"
},
{
"filter_name": "model",
"filter_value": "Cascadia 12564ST"
},
{
"filter_name": "newListing",
"filter_value": "false"
},
{
"filter_name": "numberOfBunks",
"filter_value": "2"
},
{
"filter_name": "numberOfDriveAxles",
"filter_value": "2"
},
{
"filter_name": "state",
"filter_value": "MN"
},
{
"filter_name": "transmissionMake",
"filter_value": "Detroit"
},
{
"filter_name": "transmissionSpeed",
"filter_value": "12"
},
{
"filter_name": "transmissionType",
"filter_value": "Automatic"
},
{
"filter_name": "type",
"filter_value": "Sleeper Tractor"
},
{
"filter_name": "collisionWarning",
"filter_value": "No"
},
{
"filter_name": "canada",
"filter_value": null
},
{
"filter_name": "unitedStates",
"filter_value": "MN"
},
{
"filter_name": "countryExt",
"filter_value": "United States"
},
{
"filter_name": "promotionVehicle",
"filter_value": "true"
},
{
"filter_name": "promotions",
"filter_value": "Current Deals"
},
{
"filter_name": "promotions",
"filter_value": "Save on Select Sleeper Tractors"
},
{
"filter_name": "promotions",
"filter_value": "Save on Select Sleeper Tractors. Save an additional $5,000 when financing with Premier Financing"
}
],
"slider_filter_integer": [
{
"filter_name": "numeric_mileage",
"filter_value": 701830
},
{
"filter_name": "year",
"filter_value": 2015
}
],
"slider_filter_float": [
{
"filter_name": "numeric_retail_price",
"filter_value": 44500
},
{
"filter_name": "numeric_wholesale_price",
"filter_value": 59500
}
],
"basic_filter": {},
"rowNum": 2465,
"displayManagerspecial": null,
"displayPromotions": "true",
"canada": null,
"unitedStates": "MN",
"mgrSpecialRetail": "false",
"mgrSpecialWholesale": "false",
"promotions": []
}
}
]
}
}
Output of GET _cat/shards/vehicle*?v from both the nodes
node1
index shard prirep state docs store ip node
vehicle_inventory 0 p STARTED 120528 9.9mb 3.178.159.250 qa-esearch-n1
vehicle_inventory 0 r UNASSIGNED
node2
index shard prirep state docs store ip node
vehicle_inventory 0 p STARTED 121065 10.1mb 3.178.159.252 qa-esearch-n2
vehicle_inventory 0 r UNASSIGNED
Please observe there is a difference in storage size (9.9mb and 10.1mb). why is the size difference.
Output of GET _cat/nodes?v from both nodes
node1
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
3.178.159.250 54 96 7 2.10 1.53 1.58 cdfhilmrstw * qa-esearch-n1
node2
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
3.178.159.252 30 98 6 0.35 0.21 0.17 cdfhilmrstw * qa-esearch-n2

How to filter laravel collection from given data

i have a collection data
{
"success": true,
"doctor": [
{
"id": 1,
"name": "Dr. Mayank",
"dob": "1975-01-01",
"about": "This is description",
"status": 1,
"rating": 2,
"rating_given_by": 1,
"alternative_number": "7686876876",
"profile_photo": [],
"speciality": [
{
"id": 3,
"name": "Acupuncture",
"image": null,
"dashboard_flag": 1
},
{
"id": 4,
"name": "Acupuncturist",
"image": null,
"dashboard_flag": 1
},
{
"id": 1,
"name": "Accident and emergency medicine",
"image": "http://192.168.16.21/remidify/media/174/detail.png",
"dashboard_flag": 1
}
],
"service": [
{
"id": 78,
"name": "Correction of gummy smile",
"cost": "12.00"
},
{
"id": 77,
"name": "Dental aesthetics",
"cost": "43.00"
}
],
"clinics": [
{
"id": 1,
"name": "akram",
"entity_id": 1,
"entity_type": "App\Doctor",
"contact_number": "2132132132132",
"status": 0,
"consultancy_fee": "12.00",
"available_today": "No",
"owner_name": "Dr. Mayank",
"pivot": {
"doctor_id": 1,
"clinic_id": 1
},
"address": {
"id": 1,
"address_1": "asdasdasdsa",
"address_2": "",
"locality": "downtown",
"city": "noida",
"state": "up",
"postal_code": "41561566"
},
"speciality": [],
"service": [
{
"id": 11,
"name": "Laminates",
"cost": "20.00"
},
{
"id": 12,
"name": "Dental surgery",
"cost": "300.00"
}
],
"clinic_image": [
{
"id": 7,
"model_id": 1,
"model_type": "App\Clinic",
"collection_name": "clinic_image",
"file_name": "1494863957588.566162.jpg",
"disk": "media",
"url": "http://192.168.16.21/remidify/media/7/1494863957588.566162.jpg"
}
],
"id_image": [
{
"id": 8,
"model_id": 1,
"model_type": "App\Clinic",
"collection_name": "id_image",
"file_name": "1494863966218.348877.jpg",
"disk": "media",
"url": "http://192.168.16.21/remidify/media/8/1494863966218.348877.jpg"
}
],
"location": {
"id": 1,
"latitude": 0,
"longitude": 0,
"entity_id": 1,
"entity_type": "App\Clinic",
"created_at": "2017-05-16 03:00:10",
"updated_at": "2017-05-16 03:00:10"
},
"clinic_timings": [
{
"day": "sun",
"opens_at": "09:28:00",
"closes_at": "21:28:00"
}
]
}
],
"education": [
{
"id": 19,
"degree": "MBBS",
"university": "Univercity",
"year": "2017",
"entity_id": 1,
"entity_type": "App\Doctor",
"created_at": "2017-05-16 05:44:11",
"updated_at": "2017-05-16 05:44:11",
"location": "Delhi"
}
],
"experience": [
{
"id": 19,
"hospital": "Hospital name",
"post": "pta ni hai",
"from": "1970-01-01",
"to": "0000-00-00",
"entity_id": 1,
"entity_type": "App\Doctor",
"created_at": "2017-05-16 05:44:12",
"updated_at": "2017-05-16 05:44:12",
"location": "Locations12",
"is_currently_working": 1
}
],
"registration": {
"id": 1,
"registration_number": "Reg # 2324324",
"registration_year": 1975,
"registration_council": "Council",
"experience": null,
"doctor_id": 1,
"created_at": "2017-05-16 02:56:37",
"updated_at": "2017-05-16 02:56:37",
"adhaar_number": "232131231232",
"id_proof": [
{
"id": 2,
"model_id": 1,
"model_type": "App\DoctorRegistration",
"collection_name": "id_proof",
"file_name": "1494863680447.329102.jpg",
"disk": "media",
"url": "http://192.168.16.21/remidify/media/2/1494863680447.329102.jpg"
}
],
"registration_proof": [
{
"id": 3,
"model_id": 1,
"model_type": "App\DoctorRegistration",
"collection_name": "registration_proof",
"file_name": "1494863687436.266846.jpg",
"disk": "media",
"url": "http://192.168.16.21/remidify/media/3/1494863687436.266846.jpg"
}
],
"qualification_proof": [
{
"id": 4,
"model_id": 1,
"model_type": "App\DoctorRegistration",
"collection_name": "qualification_proof",
"file_name": "1494863695576.803955.jpg",
"disk": "media",
"url": "http://192.168.16.21/remidify/media/4/1494863695576.803955.jpg"
}
]
},
"preference": {
"availability": 1,
"appointment_confirmation_method": "manual",
"average_time": 7,
"holiday_from": null,
"holiday_till": null,
"patients_per_hour": null,
"preferred_appointment_type": "timeslot",
"appointment_frequency": null,
"preferred_payment_method": [
{
"payment_method": "cash"
},
{
"payment_method": "online"
}
]
},
"user": null,
"doctor_clinic": [
{
"doctor_id": 1,
"clinic_id": 1,
"consultancy_fee": "12.00",
"deleted_at": null,
"workdays": [
{
"day": "sun",
"available": 1,
"workhours": [
{
"from": "09:28:00",
"to": "21:28:00"
}
]
}
],
"service": []
}
]
}
]
}
Now how can i find the doctors whose "about or specialty name" matches with some given search string.
Thanks in advance.
Try using dd() helper and use like this below
$youcollectionvariables = { "success": true, "doctor": [ { "id": 1, "name": "Dr. Mayank", "dob": "1975-01-01"................. }
dd($youcollectionvariables)
you will see a formatted data and can find what you need clearly.
Hope that helps.

Error when saving composites id inside a for loop

I am trying to persist some objects that have a composite id. If I am only sending an array with one element it works fine, but it the array has more than one it throws an exception when saving the first one. public boolean
addParamsToChart(List<ChartParams> chartParams, Long chartId) {
List<ChartParams> chartParamsList = new ArrayList<>();
for(ChartParams chartParam: chartParams) {
ChartParamsId id = new ChartParamsId();
// id.setChartId(chartId);
id.setChartId(chartParam.getChart().getId());
id.setParamId(chartParam.getParam().getId());
id.setContextSourceId(chartParam.getContextSource().getId());
chartParam.setChartParamsId(id);
if(chartParamsRepository.save(chartParams) !=null) {
chartParamsList.add(chartParam);
}
}
if(chartParamsList.size()!=chartParams.size()) {
// something went wrong, delete previous inserted
deleteChartParams(chartParamsList);
chartRepository.delete(chartId);
return false;
}
return true;
}
[{
"chart": {
"id": 49,
"cv": {
"id": 1,
"name": "Money",
"category": {
"id": 1,
"name": "Euros"
},
"definition": "\"European curreny.\" [EU:euro]",
"enabled": true,
"cvid": "CC:1010"
},
"accountType": {
"id": 1,
"name": "saving"
},
"name": "Euro saving charts"
},
"param": {
"id": 8,
"name": "Totals",
"isFor": "Currency"
},
"contextSource": {
"id": 3,
"name": "euro",
"internal": "eu",
"abbreviatedName": "eu"
} }]
But for this having two objects inside instead of one is not working, throwing an exception at the first save.
[{
"chart": {
"id": 52,
"cv": {
"id": 55,
"name": "Stocks",
"category": {
"id": 1,
"name": "Stocks"
},
"definition": "\"General stocks.\" [GS:ST]",
"enabled": true,
"cvid": "ST:0111"
},
"accountType": {
"id": 1,
"name": "saving"
},
"name": "Stock saving chart"
},
"param": {
"id": 8,
"name": "Totals",
"isFor": "Currency"
},
"contextSource": {
"id": 6,
"name": "stock",
"internal": "st",
"abbreviatedName": "st"
} }, {
"chart": {
"id": 52,
"cv": {
"id": 55,
"name": "Stocks",
"category": {
"id": 1,
"name": "Stocks"
},
"definition": "\"General stocks.\" [GS:ST]",
"enabled": true,
"cvid": "ST:0111"
},
"accountType": {
"id": 1,
"name": "saving"
},
"name": "Stock saving chart"
},
"param": {
"id": 8,
"name": "Totals",
"isFor": "Currency"
},
"contextSource": {
"id": 7,
"name": "Sold stock",
"internal": "st_sold",
"abbreviatedSequence": "st_sold"
} }]
The exception I got is:
org.hibernate.id.IdentifierGenerationException: null id generated for:class eu.stocks.chart.chartParams.ChartParams

REQL to match string expression

I have the following json:
{
"release": {
"genres": {
"genre": "Electronic"
},
"identifiers": {
"identifier": [
{
"description": "Text",
"value": "5 709498 101026",
"type": "Barcode"
},
{
"description": "String",
"value": 5709498101026,
"type": "Barcode"
}
]
},
"status": "Accepted",
"videos": {
"video": [
{
"title": "Future 3 - Renaldo",
"duration": 446,
"description": "Future 3 - Renaldo",
"src": "http://www.youtube.com/watch?v=hpc9aQpnUjc",
"embed": true
},
{
"title": "Future 3 - Silver M from album We are the Future / 1995 Denmark / Archivos de Kraftwerkmusik",
"duration": 461,
"description": "Future 3 - Silver M from album We are the Future / 1995 Denmark / Archivos de Kraftwerkmusik",
"src": "http://www.youtube.com/watch?v=nlcHRI8iV4g",
"embed": true
},
{
"title": "Future 3 - Bubbles At Dawn",
"duration": 710,
"description": "Future 3 - Bubbles At Dawn",
"src": "http://www.youtube.com/watch?v=ABBCyvGMOFw",
"embed": true
}
]
},
"labels": {
"label": {
"catno": "APR 010CD",
"name": "April Records"
}
},
"companies": {
"company": {
"id": 26184,
"catno": "",
"name": "Voices Of Wonder",
"entity_type_name": "Published By",
"resource_url": "http://api.discogs.com/labels/26184",
"entity_type": 21
}
},
"styles": {
"style": [
"Abstract",
"IDM",
"Downtempo"
]
},
"formats": {
"format": {
"text": "",
"name": "CD",
"qty": 1,
"descriptions": {
"description": "Album"
}
}
},
"country": "Denmark",
"id": 5375,
"released": "1995-00-00",
"artists": {
"artist": {
"id": 5139,
"anv": "",
"name": "Future 3",
"role": "",
"tracks": "",
"join": ""
}
},
"title": "We Are The Future 3",
"master_id": 638422,
"tracklist": {
"track": [
{
"position": 1,
"duration": "8:04",
"title": "Future 3"
},
{
"position": 2,
"duration": "7:38",
"title": "Silver M"
},
{
"position": 3,
"duration": "7:27",
"title": "Renaldo"
},
{
"position": 4,
"duration": "6:04",
"title": "B.O.Y.D."
},
{
"position": 5,
"duration": "6:12",
"title": "Fumble"
},
{
"position": 6,
"duration": "6:12",
"title": "Dawn"
},
{
"position": 7,
"duration": "11:54",
"title": "Bubbles At Dawn"
},
{
"position": 8,
"duration": "6:03",
"title": "D.A.W.N. At 6"
},
{
"position": 9,
"duration": "8:50",
"title": 4684351684651
}
]
},
"data_quality": "Needs Vote",
"extraartists": {
"artist": [
{
"id": 2647642,
"anv": "",
"name": "Danesadwork",
"role": "Cover",
"tracks": "",
"join": ""
},
{
"id": 2647647,
"anv": "",
"name": "Djon Edvard Petersen",
"role": "Photography By",
"tracks": "",
"join": ""
},
{
"id": 114164,
"anv": "",
"name": "Anders Remmer",
"role": "Written-By",
"tracks": "",
"join": ""
},
{
"id": 435979,
"anv": "",
"name": "Jesper Skaaning",
"role": "Written-By",
"tracks": "",
"join": ""
},
{
"id": 15691,
"anv": "",
"name": "Thomas Knak",
"role": "Written-By",
"tracks": "",
"join": ""
}
]
},
"notes": "© 1995 April Records APS ℗ 1995 April Records APS"
}
}
I am trying to get those titles which end with 'At Dawn'.
I am using the following command
r.db("discogs1").table("releases").filter(function(doc){ return doc('release')('title').match('At Dawn$')})
But I get errors as follows:
RqlRuntimeError: Expected type STRING but found NUMBER in:r.db("discogs1").table("releases").filter(function(var_24) { return var_24("release")("title").match("At Dawn$"); })
I tried different combinations but I can't seem to get it to work
It seems that some of your documents don't have a row('release')('title') property that is a string. Some of them are numbers, so when you try to call .match on them, they throw an error because .match only works on strings.
To see if this is true, try the following:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().ne('STRING'))
.count()
Ideally, the result of this should be 0, since no document should have a title property that's not a string. If it's higher than 0, that's why you're getting an error.
If you want to only get documents where the title is a string, you can do the following:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().eq('STRING'))
.filter(function(doc){ return doc('release')('title').match('At Dawn$')})
This query will work, because it will filter our all documents where the title is not a string.
If you want to coerce all title into strings, you can do the following:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().ne('STRING'))
.merge(function (row) {
return {
'title': row('title').coerceTo('string')
}
})
If you want to delete all documents where the title is not a string, you can do this:
r.db("discogs1").table("releases")
.filter(r.row('release')('title').typeOf().ne('STRING'))
.delete()

datatables number of results from JSON

I have a pretty simple question on datatables for which I couldn't find an answer.
I'm using Spring MVC to generate a JSON, which has the following format:
{
"content": [
{
"id": 1,
"firstName": "\u00d6sten",
"lastName": "Dixon",
"email": "hdixon0#forbes.com",
"country": "Belarus",
"ipAddress": "196.228.168.184",
"creditCard": "060479202511002980",
"company": "Trunyx",
"timezone": "Atlantic\/South_Georgia",
"iban": "LV55 ECXH IGFF GSEW YHMU G",
"latitude": "52.644",
"longitude": "25.2027",
"race": "Blackfeet"
},
{
"id": 2,
"firstName": "Agn\u00e8s",
"lastName": "Perry",
"email": "wperry1#blogspot.com",
"country": null,
"ipAddress": "75.63.229.226",
"creditCard": "5191970963453131",
"company": "Tanoodle",
"timezone": "Asia\/Kabul",
"iban": "TN75 8279 0633 7374 0209 2905",
"latitude": "11.97444",
"longitude": "-86.09417",
"race": null
},
// more
],
"totalPages": 51,
"last": false,
"totalElements": 503,
"size": 10,
"number": 0,
"sort": null,
"numberOfElements": 10,
"first": true
}
I'd like to display the result using datatables, however it looks like it's expecting a "iTotalRecords" for example, where my JSON has a "totalElements"
How can I specify that mapping?
$(document).ready(function () {
$('#datatable').DataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "members",
"sAjaxDataProp" : 'content',
"columns": [
{ "data": "id" },
{ "data": "firstName" },
{ "data": "lastName" },
{ "data": "email" },
{ "data": "country" },
{ "data": "ipAddress" },
{ "data": "creditCard" },
{ "data": "company" },
{ "data": "timezone" },
{ "data": "iban" },
{ "data": "latitude" },
{ "data": "longitude" },
{ "data": "race" },
]
});

Resources