JsonExtractor with OpenScript - openscript

Like http.solve and http.solveXpath is there anything similar for JSON.
In the snipped provided, I have to capture complete master node based on condition that the person should be either MD or MD,PhD.
Json syntax with Jmeter: $..[?(#.person_credentials == 'MD' || #.person_credentials == 'MD,PhD')]
Looking for similar thing that can be implemented in OpenScript
Kindly provide ur inputs
Thanks,
Sumit
[{
"person_party_id": 3663409,
"person_party_number": "1199490",
"person_party_name": "Andrea Ward",
"person_obj_version_num": 2,
"person_profile_id": 31036987,
"person_profile_obj_version_num": 2,
"person_name": "Andrea Lee Ward",
"person_pre_name_adjunct": {
"lv_type_id": "TCA|CONTACT_TITLE",
"code": "MS."
},
"person_first_name": "Andrea",
"person_middle_name": "Lee",
"person_last_name": "Ward",
"person_name_suffix": null,
"person_academic_title": null,
"person_credentials": "HT(ASCP)",
"person_ptr_number": null,
"relationship_id": 1760699,
"relationship_obj_version_num": 2,
"relationship_party_id": 3959866,
"relationship_party_number": "52898",
"relationship_party_name": "Andrea Ward-Chester County Hospital-52898-52898-52898-52898",
"relationship_party_obj_version_num": 2,
"org_contact_id": 2006288,
"org_contact_obj_version_num": 2,
"is_generic": false,
"email": {
"contact_point_id": 1170409,
"email_address": "andrea.ward2#uphs.upenn.edu",
"object_version_number": 2
},
"phone": {
"contact_point_id": 1170414,
"phone_country_code": "1",
"phone_area_code": "610",
"phone_number": "431-5561",
"phone_extension": null,
"object_version_number": 2
},
"roles": [{
"lv_type_id": "TCA|CONTACT_ROLE_TYPE",
"code": "ELABUSER"
}, {
"lv_type_id": "TCA|CONTACT_ROLE_TYPE",
"code": "PRIMREL"
}],
"contact_id": 3663409,
"first_name": "Andrea",
"last_name": "Ward",
"credentials": "HT(ASCP)",
"emails": [{
"contact_point_id": 1170409,
"email_address": "andrea.ward2#uphs.upenn.edu",
"related_accounts": null,
"object_version_number": 2
}],
"phone_numbers": [{
"type": "Telephone",
"contact_point_id": 1170414,
"phone_country_code": "1",
"phone_area_code": "610",
"phone_number": "431-5561",
"phone_extension": null,
"related_accounts": null,
"object_version_number": 2
}, {
"type": "Fax",
"contact_point_id": 1170417,
"phone_country_code": "1",
"phone_area_code": "610",
"phone_number": "430-2935",
"phone_extension": null,
"related_accounts": null,
"object_version_number": 3
}]
}, {
"person_party_id": 3620546,
"person_party_number": "208332",
"person_party_name": "James Heald",
"person_obj_version_num": 5,
"person_profile_id": 15949851,
"person_profile_obj_version_num": 2,
"person_name": "James Irwin Heald",
"person_pre_name_adjunct": {
"lv_type_id": "TCA|CONTACT_TITLE",
"code": "DR."
},
"person_first_name": "James",
"person_middle_name": "Irwin",
"person_last_name": "Heald",
"person_name_suffix": null,
"person_academic_title": null,
"person_credentials": "MD,PhD",
"person_ptr_number": null,
"relationship_id": 1728597,
"relationship_obj_version_num": 2,
"relationship_party_id": 3927762,
"relationship_party_number": "18195",
"relationship_party_name": "James Heald-Chester County Hospital-18195-18195-18195-18195",
"relationship_party_obj_version_num": 2,
"org_contact_id": 1971610,
"org_contact_obj_version_num": 2,
"is_generic": false,
"email": {
"contact_point_id": 1167675,
"email_address": "james.heald#uphs.upenn.edu",
"object_version_number": 2
},
"phone": {
"contact_point_id": 1167678,
"phone_country_code": "1",
"phone_area_code": "610",
"phone_number": "431-5471",
"phone_extension": null,
"object_version_number": 2,
"type": "Telephone"
},
"roles": [{
"lv_type_id": "TCA|CONTACT_ROLE_TYPE",
"code": "ELABEDSTADM"
},
{
"lv_type_id": "TCA|CONTACT_ROLE_TYPE",
"code": "ELABSTADM"
},
{
"lv_type_id": "TCA|CONTACT_ROLE_TYPE",
"code": "PRIMREL"
}
],
"contact_id": 3620546,
"first_name": "James",
"last_name": "Heald",
"credentials": "MD,PhD",
"emails": [{
"contact_point_id": 1167675,
"email_address": "james.heald#uphs.upenn.edu",
"related_accounts": null,
"object_version_number": 2
}],
"phone_numbers": [{
"type": "Telephone",
"contact_point_id": 1167678,
"phone_country_code": "1",
"phone_area_code": "610",
"phone_number": "431-5471",
"phone_extension": null,
"related_accounts": null,
"object_version_number": 2
},
{
"type": "Fax",
"contact_point_id": 1167683,
"phone_country_code": "1",
"phone_area_code": "610",
"phone_number": "430-2935",
"phone_extension": null,
"related_accounts": null,
"object_version_number": 2
}
]
}]

Related

How to insert header tags to API Json

Hello im making a GET api in laravel that shows values from database and im trying to make it that the returned json result to have a header tag an example is this public api
https://dummy.restapiexample.com/api/v1/employees
As you can see this api shows the status:success and then data: , this is my code:
function getDevice()
{
return Client::all();
}
And this is the result i get in postman:
data [ //here to have a header
{
"id": 1,
"name": "Mr. Omari Schaefer DVM",
"email": "kulas.julian#example.net",
"phone_number": "0697830800",
"age": "29",
"salary": "150",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 2,
"name": "Hattie Brakus",
"email": "deckow.coby#example.com",
"phone_number": "0697830800",
"age": "30",
"salary": "565",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 3,
"name": "Sabrina Rosenbaum",
"email": "kautzer.madison#example.net",
"phone_number": "0697830800",
"age": "31",
"salary": "254",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 4,
"name": "Ms. Fiona Fritsch",
"email": "juwan.damore#example.net",
"phone_number": "0697830800",
"age": "32",
"salary": "029",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 5,
"name": "Michael Dooley",
"email": "hayes.reinhold#example.org",
"phone_number": "0697830800",
"age": "33",
"salary": "265",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 6,
"name": "Prof. Kelley Koepp Jr.",
"email": "kutch.jessie#example.org",
"phone_number": "0697830800",
"age": "34",
"salary": "688",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 7,
"name": "Herminia McClure PhD",
"email": "ywillms#example.com",
"phone_number": "0697830800",
"age": "35",
"salary": "103",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 8,
"name": "Morton Considine",
"email": "lesly.pfeffer#example.com",
"phone_number": "0697830800",
"age": "36",
"salary": "804",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 9,
"name": "Katlyn Muller",
"email": "peter93#example.net",
"phone_number": "0697830800",
"age": "37",
"salary": "695",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 10,
"name": "Wilber Stehr",
"email": "bmckenzie#example.net",
"phone_number": "0697830800",
"age": "38",
"salary": "941",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 11,
"name": "Test User",
"email": "test#example.com",
"phone_number": "0697830800",
"age": "60",
"salary": "448",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
}
]
What im trying to do is:
[
{
"id": 1,
"name": "Mr. Omari Schaefer DVM",
"email": "kulas.julian#example.net",
"phone_number": "0697830800",
"age": "29",
"salary": "150",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 2,
"name": "Hattie Brakus",
"email": "deckow.coby#example.com",
"phone_number": "0697830800",
"age": "30",
"salary": "565",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 3,
"name": "Sabrina Rosenbaum",
"email": "kautzer.madison#example.net",
"phone_number": "0697830800",
"age": "31",
"salary": "254",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 4,
"name": "Ms. Fiona Fritsch",
"email": "juwan.damore#example.net",
"phone_number": "0697830800",
"age": "32",
"salary": "029",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 5,
"name": "Michael Dooley",
"email": "hayes.reinhold#example.org",
"phone_number": "0697830800",
"age": "33",
"salary": "265",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 6,
"name": "Prof. Kelley Koepp Jr.",
"email": "kutch.jessie#example.org",
"phone_number": "0697830800",
"age": "34",
"salary": "688",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 7,
"name": "Herminia McClure PhD",
"email": "ywillms#example.com",
"phone_number": "0697830800",
"age": "35",
"salary": "103",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 8,
"name": "Morton Considine",
"email": "lesly.pfeffer#example.com",
"phone_number": "0697830800",
"age": "36",
"salary": "804",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 9,
"name": "Katlyn Muller",
"email": "peter93#example.net",
"phone_number": "0697830800",
"age": "37",
"salary": "695",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 10,
"name": "Wilber Stehr",
"email": "bmckenzie#example.net",
"phone_number": "0697830800",
"age": "38",
"salary": "941",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
},
{
"id": 11,
"name": "Test User",
"email": "test#example.com",
"phone_number": "0697830800",
"age": "60",
"salary": "448",
"created_at": "2023-02-17T08:36:00.000000Z",
"updated_at": "2023-02-17T08:36:00.000000Z"
}
]
function getDevice()
{
return ['data' =>
Client::all(),
};
Please refer to the below solution for every response :
return response()->json('status' => 'success','message' => 'Client listing successfully.','data' => Client::all());
If you know how to use the helper function in Laravel then Please used the below for all responses:
Example :
In Controller, Just add the below line :
return apiResponse('success','Client listed successfully',Client::all()]);
if (!function_exists('apiResponse')) {
function apiResponse($status = null, $message = null, $data = null, $code = 200, $extra = []) {
$response = [
'status' => $status,
'message' => $message,
'data' => $data,
];
if(!empty($extra)){
$response = array_merge($response,$extra);
}
return response()->json($response, $code);
}
}
I think this will help you a lot.

How do I extract unique data from Hyperledger Composer using query or js

I want to get unique data from a duplicates data at Hyperledger Composer. How can I achieve this?
suppose I have a data like this
[
{
"$class": "org.stock.mynetwork.Commodity",
"time": "1",
"dataType" : "in",
"productName": "A",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "2",
"dataType": "in",
"productName": “A",
"quantity": 1,
"country": "Unknown",
"owner": "BABA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "3",
"dataType": "out",
"productName": "C",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "4",
"dataType": "in",
"productName": "C",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "5",
"dataType": "out",
"productName": "B",
"quantity": 1,
"country": "Unknown",
"owner": "BABA"
}
]
what I want to get is a list of unique Product name.
So the result I want maybe something like this
[
{
"$class": "org.stock.mynetwork.Commodity",
"time": "1",
"dataType" : "in",
"productName": "A",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "3",
"dataType": "out",
"productName": "C",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "5",
"dataType": "out",
"productName": "B",
"quantity": 1,
"country": "Unknown",
"owner": "BABA"
}
]
I don't really care about the sequence. I just want to know what productName do I have in my database.
I think this needs something to do with the logic.js part. I can do queries and get the data using post method. But I don't know how to do that using logic.js
I don't know how to get the data from logic.js. The example at official page only delete or trade. They don't return a new data.
any help is appreciated. I want to know how to send data using the js.
The js code to get the unique productname from your data would be
const data =[
{
"$class": "org.stock.mynetwork.Commodity",
"time": "1",
"dataType" : "in",
"productName": "A",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "3",
"dataType": "out",
"productName": "A",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "5",
"dataType": "out",
"productName": "B",
"quantity": 1,
"country": "Unknown",
"owner": "BABA"
}
];
const distinctProductName = [...new Set(data.map(x => x.productName))];
You will have your distinct ProductName in distinctProductName but you won't have the details of product. From your questions, it didnot feel necessary too. If you need the details too, you could do something like
const data =[
{
"$class": "org.stock.mynetwork.Commodity",
"time": "1",
"dataType" : "in",
"productName": "A",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "3",
"dataType": "out",
"productName": "A",
"quantity": 1,
"country": "Unknown",
"owner": "GAGA"
},
{
"$class": "org.stock.mynetwork.Commodity",
"time": "5",
"dataType": "out",
"productName": "B",
"quantity": 1,
"country": "Unknown",
"owner": "BABA"
}
];
const result = Array.from(new Set(data.map(x => x.productName)))
.map(productName => {
return{
productName: productName,
dataType : data.find(x => x.productName ===productName).dataType
//you can obtain other values as I obtained dataType
};
});
You will have your data in result.

Laravel apply sortBy to a related models collection

I am using the below code:
$greatDeals = $greatDealsinitial->sortBy(function ($deal, $key) {
return $deal->hotel->room[0]->price;
});
Here room is an array, I want to sort this collection by price in the room array.
But I can't use return $row->hotel->room->price;
So how can I sort this?
my collection :
[
{
"id": 2,
"hotel_id": 1,
"deal_code": "sfg",
"date": "2018-04-13 00:00:00",
"discount": 12,
"status": 1,
"created_at": "2018-04-13 11:21:18",
"updated_at": "2018-04-13 11:21:18",
"deleted_at": null,
"client_id": 1,
"hotel": {
"id": 1,
"name": "Aloft Dongguan Songshan Lake",
"address": "Dongguan, China, 511700",
"phone": "76982106666",
"country": "101",
"country_name": "India",
"state": "35",
"state_name": "Tamil Nadu",
"city": "3551",
"city_name": "Abiramam",
"area": null,
"pincode": "511700",
"nearest_airport": null,
"nearest_railway": null,
"star": null,
"check_in": null,
"check_out": null,
"lat": "22.929869",
"lng": "113.89232800000002",
"description": null,
"astatus": "1",
"status": "0",
"created_at": "2018-04-13 10:27:30",
"updated_at": "2018-04-13 10:27:48",
"client_id": 1,
"hotel_age": null,
"hotel_privilege": "asdf",
"departure": "sdaf",
"checkout_fee": "asdf",
"book_policy": "sadf",
"hotel_secured": null,
"hotel_pets": null,
"hotel_other": null,
"room": [
{
"id": 3,
"roomtype_id": 2,
"room_count": null,
"max_adult": 2,
"max_children": 1,
"capacity": 3,
"room_number": null,
"floor": null,
"number": null,
"name": null,
"city_name": "Abiramam",
"city": 3551,
"price": "200.00",
"extra_bed_price": null,
"astatus": "1",
"status": "0",
"created_at": "2018-04-13 12:37:11",
"updated_at": "2018-04-13 12:37:52",
"deleted_at": null,
"client_id": 1,
"hotel_id": 1
},
{
"id": 1,
"roomtype_id": 1,
"room_count": null,
"max_adult": 2,
"max_children": 1,
"capacity": 3,
"room_number": null,
"floor": null,
"number": null,
"name": null,
"city_name": "Abiramam",
"city": 3551,
"price": "435.00",
"extra_bed_price": null,
"astatus": "1",
"status": "0",
"created_at": "2018-04-13 10:33:24",
"updated_at": "2018-04-13 11:21:38",
"deleted_at": null,
"client_id": 1,
"hotel_id": 1
}
]
}
},
{
"id": 4,
"hotel_id": 2,
"deal_code": "ertgerf",
"date": "2018-04-13 00:00:00",
"discount": 1,
"status": 1,
"created_at": "2018-04-13 11:47:39",
"updated_at": "2018-04-13 11:53:45",
"deleted_at": null,
"client_id": 2,
"hotel": {
"id": 2,
"name": "Temperance Lane",
"address": "Temperance Ln, Sydney NSW 2000, Australia",
"phone": "9842814927",
"country": "14",
"country_name": "Austria",
"state": "281",
"state_name": "Carinthia",
"city": "6843",
"city_name": "Maria Rain",
"area": "test",
"pincode": "2000",
"nearest_airport": "demo",
"nearest_railway": "test",
"star": null,
"check_in": "09:30 AM",
"check_out": "04:30 PM",
"lat": "-33.86963590000001",
"lng": "151.20667979999996",
"description": "test description",
"astatus": "1",
"status": "0",
"created_at": "2018-04-13 10:43:16",
"updated_at": "2018-04-13 11:41:25",
"client_id": 2,
"hotel_age": null,
"hotel_privilege": "testtesttesttesttesttesttesttesttesttesttest",
"departure": "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest",
"checkout_fee": "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest",
"book_policy": "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest",
"hotel_secured": null,
"hotel_pets": null,
"hotel_other": "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest",
"room": [
{
"id": 2,
"roomtype_id": 1,
"room_count": null,
"max_adult": 2,
"max_children": 3,
"capacity": 5,
"room_number": null,
"floor": null,
"number": null,
"name": null,
"city_name": "Maria Rain",
"city": 6843,
"price": "345.00",
"extra_bed_price": null,
"astatus": "1",
"status": "0",
"created_at": "2018-04-13 10:46:04",
"updated_at": "2018-04-13 10:47:05",
"deleted_at": null,
"client_id": 2,
"hotel_id": 2
}
]
}
}
]
This sorts the rooms of each hotel per price:
$greatDealsinitial->each(function($deal) {
$deal->hotel->setRelation('room', $deal->hotel->room->sortBy('price'));
});
$greatDeals = $greatDealsinitial->hotel->room->sortBy('price')
if this array looks
[
['price' => 0],
['price' => 1],
['price' => 3]
]

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.

Queries on ElasticSearch

I have a document which look like this,
{
"_index": "w3-commsvc",
"_type": "message",
"_id": "h98yv662",
"_score": 1,
"_source": {
"messageId": "h98yv662",
"campaignName": "src_checkoutAbandon",
"campaignId": "cId_w3_website",
"states": [
{
"Delivered": 790709218
},
{
"open": 1288775055
},
{
"click": 319518555
},
{
"DEFERRED": 2137606534
}
],
"clientName": "w3_website",
"templateId": "test",
"opens": [
{
"url": "www.something.com",
"id": "t26jj783",
"userAgent": {
"browser": {
"family": "IE",
"version": "11.0",
"major": "11",
"minor": "0",
"patch": null
},
"os": {
"family": "Windows_XP",
"version": null,
"versionPopularName": null,
"major": null,
"minor": null,
"patch": null,
"patchMinor": null
},
"device": {
"family": "Other",
"type": "Computer"
}
},
"timestamp": "1372366437"
},
{
"url": "www.something.com",
"id": "t98ef285",
"userAgent": {
"browser": {
"family": "IE",
"version": "11.0",
"major": "11",
"minor": "0",
"patch": null
},
"os": {
"family": "Windows_XP",
"version": null,
"versionPopularName": null,
"major": null,
"minor": null,
"patch": null,
"patchMinor": null
},
"device": {
"family": "Other",
"type": "Computer"
}
},
"timestamp": "717918284"
}
],
"clicks": [
{
"url": "www.something.com",
"id": " j60te707",
"userAgent": {
"browser": {
"family": "IE",
"version": "11.0",
"major": "11",
"minor": "0",
"patch": null
},
"os": {
"family": "Windows_XP",
"version": null,
"versionPopularName": null,
"major": null,
"minor": null,
"patch": null,
"patchMinor": null
},
"device": {
"family": "Other",
"type": "Computer"
}
},
"timestamp": "1293320728"
},
{
"url": "www.something.com",
"id": " c63bc623",
"userAgent": {
"browser": {
"family": "IE",
"version": "11.0",
"major": "11",
"minor": "0",
"patch": null
},
"os": {
"family": "Windows_XP",
"version": null,
"versionPopularName": null,
"major": null,
"minor": null,
"patch": null,
"patchMinor": null
},
"device": {
"family": "Other",
"type": "Computer"
}
},
"timestamp": "624917313"
},
{
"url": "www.something.com",
"id": " f10qm",
"userAgent": {
"browser": {
"family": "Firefox",
"version": "11.0",
"major": "11",
"minor": "0",
"patch": null
},
"os": {
"family": "Windows_XP",
"version": null,
"versionPopularName": null,
"major": null,
"minor": null,
"patch": null,
"patchMinor": null
},
"device": {
"family": "Other",
"type": "Computer"
}
},
"timestamp": "334734507"
}
]
}
}
Now using the above documents i need the following answer for the following queries,
1 - I need the terms count of each state for a certain clientName.
2 - Total sum of length of each opens array in the document.
3 - Open and click stats for each browsers.

Resources