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
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.
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()