Hypen in response data is throwing error when setting as global variable for nested response - postman

I have a post man request. Which returns a response data as:
[
{
"id": "7ca27c09-2b67-417e-b367-f97d49824a2f",
"tags": [],
"type": "ApplicationProfile",
"userId": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"profile": {
"User-Profile": {
"PHI": {
"gender": "Male",
"surgeryDate": {
"value": "2017-06-06"
},
"surgeryType": {
"value": "gastricBand"
},
"heightInches": "72",
"approvalPhase": "2",
"profileImageUrl": "",
"motivationalImageUrl": ""
},
"PII": {
"mail": "c11#c111.com",
"lastName": "",
"firstName": "name1",
"shouldReceiveNotifications": true
}
},
"motivationalGoals": [
{
"goal": "Improving health",
"goalId": "2957"
},
{
"goal": "Relieving pain",
"goalId": "2958"
},
{
"goal": "Feeling better",
"goalId": "2960"
}
]
},
"version": 35,
"createdBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"lastModifiedBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"applicationName": "Health Partner",
"createdDateTime": "2017-06-08T16:08:32.497Z",
"lastModifiedDateTime": "2017-06-09T13:23:03.503Z"
},
{
"id": "091b5ebd-b096-436e-a703-f97f0ae77baf",
"tags": [
"Application-Profile"
],
"type": "ApplicationProfile",
"userId": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"profile": {
"User-Profile": {
"PHI": {
"gender": "",
"surgeryDate": {
"value": "2017-06-01"
},
"surgeryType": {
"value": ""
},
"heightInches": "72",
"approvalPhase": "2",
"profileImageUrl": "",
"motivationalImageUrl": ""
},
"PII": {
"mail": "c11#c111.com",
"lastName": "Dev",
"firstName": "Kat",
"shouldReceiveNotifications": true
}
},
"motivationalGoals": [
{
"goal": "Improving health",
"goalId": "2957"
},
{
"goal": "Relieving pain",
"goalId": "2958"
},
{
"goal": "Feeling better",
"goalId": "2960"
}
]
},
"version": 41,
"createdBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"lastModifiedBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"applicationName": "Health Partner Weightloss",
"createdDateTime": "2017-06-03T16:19:57.811Z",
"lastModifiedDateTime": "2017-06-08T16:07:49.555Z"
}
]
I need to extract the value of the emailid and set as global variable.
here is my code:
var jsonData1 = JSON.parse(responseBody);
postman.setGlobalVariable("jsonData1",jsonData1.profile.User-Profile.PII.mail);
But I am getting error. "User is undefined".

The problem here is that the hyphen / minus sign is interpreted as the subtraction operator.
Consider changing your API and using "userProfile" instead of "User-Profile".

Related

AWS EventBridge Rule pattern "anything-but" with "prefix"

I'm trying to setup an AWS EventBridge rule that will filter all Okta user events with rawUserAgent as "anything-but" with the "prefix" libwww-perl. My question is that is there a way to chain AWS rule syntax on the same field in the event? I tried something like this, but it didn't work -
{
"detail": {
"eventType": [{
"prefix": "user.session.start"
}],
"outcome": {
"result": [{
"prefix": "FAILURE"
}]
},
"client": {
"userAgent": {
"rawUserAgent": [{
"anything-but": [{"prefix": "libwww-perl"}]
}]
}
}
}
}
Any suggestions on how I can achieve this?
Here's a sample event:
{
"version": "0",
"id": "123",
"detail-type": "SystemLog",
"source": "okta",
"account": "123",
"time": "2022-06-24T13:07:02Z",
"region": "us-east-1",
"resources": [],
"detail": {
"uuid": "123",
"published": "2022-06-24T13:07:02.586Z",
"eventType": "user.session.start",
"version": "0",
"displayMessage": "User login to Okta",
"severity": "INFO",
"client": {
"userAgent": {
"rawUserAgent": "libwww-perl/6.15",
"os": "Unknown",
"browser": "UNKNOWN"
},
"zone": "null",
"device": "Unknown",
"id": null,
"ipAddress": "192.168.1.1",
"geographicalContext": {
"city": null,
"state": null,
"country": "United States",
"postalCode": null,
"geolocation": {
"lat": 37.751,
"lon": -97.822
}
},
"ipChain": [
{
"ip": "192.168.1.1.",
"geographicalContext": {
"city": null,
"state": null
"country": "Canada",
"postalCode": null,
"geolocation": {
"lat": 37.751,
"lon": -97.822
}
},
"version": "V4",
"source": null
}
]
},
"device": null,
"actor": {
"id": "unknown",
"type": "User",
"alternateId": "abc#gmail.com",
"displayName": "unknown",
"detailEntry": null
},
"outcome": {
"result": "FAILURE",
"reason": "VERIFICATION_ERROR"
},
"target": null,
"transaction": {
"type": "WEB",
"id": "YrW29nCfOE-MgiNf6-1UkQAAA8I",
"detail": {}
},
"debugContext": {
"debugData": {
"loginResult": "VERIFICATION_ERROR",
"requestId": "abcd",
"threatSuspected": "true",
"requestUri": "",
"url": ""
}
},
"legacyEventType": "core.user_auth.login_failed",
"authenticationContext": {
"authenticationProvider": null,
"credentialProvider": null,
"credentialType": null,
"issuer": null,
"authenticationStep": 0,
"externalSessionId": "unknown",
"interface": null
},
"securityContext": {
"asNumber": 11174,
"asOrg": "qwerty",
"isp": "qwerty",
"domain": "qwerty.com",
"isProxy": false
},
"insertionTimestamp": null
}
}
You can use this pattern:
{
"detail": {
"eventType": [{
"prefix": "user.session.start"
}],
"client": {
"userAgent": {
"rawUserAgent": [{
"anything-but": {
"prefix": "libwww-perl"
}
}]
}
},
"outcome": {
"result": [{
"prefix": "FAILURE"
}]
}
}
}

Google People API - Birthday - Date object is not returned in GET requests

In Google People - people.connections.list and other GET APIs, the Date object of Birthday field is not returned for some Contacts. Have authenticated with the full People scope [https://www.googleapis.com/auth/contacts].
We also do not know the format of the "text" field to parse that, as the param can have any random string.
How to parse the birthday of a user? When will the Date object not be returned?
Sample Request
https://people.googleapis.com/v1/people/me/connections?pageSize=100&requestSyncToken=true&personFields=birthdays
Sample response Birthdays
{
"birthdays": [
{
"metadata": {
"source": {
"id": "3ebd95668aeed9d7",
"type": "CONTACT"
},
"primary": true
},
"text": "2000-07-24"
}
],
"resourceName": "people/c4520933868599957975",
"etag": "<etag>"
},
{
"birthdays": [
{
"metadata": {
"source": {
"id": "5f5712ce0861c5b0",
"type": "CONTACT"
},
"primary": true
},
"text": "1880-03-11"
}
],
"resourceName": "people/c6869980432690169264",
"etag": "<etag>"
},
{
"birthdays": [
{
"date": {
"month": 1,
"year": 1990,
"day": 26
},
"metadata": {
"source": {
"id": "a16dde58e814a36",
"type": "CONTACT"
},
"primary": true
},
"text": "01/26/1990"
}
],
"resourceName": "people/c727012367875000886",
"etag": "<etag>"
},
{
"birthdays": [
{
"date": {
"month": 1,
"year": 1998,
"day": 1
},
"metadata": {
"source": {
"id": "f350f568dd11db1",
"type": "CONTACT"
},
"primary": true
},
"text": "Jan 1, 1998"
}
],
"resourceName": "people/c1095798948755479985",
"etag": "<etag>"
},
{
"birthdays": [
{
"metadata": {
"source": {
"id": "3652e00f0d28c9f4",
"type": "CONTACT"
},
"primary": true
},
"text": "random string accept"
}
],
"resourceName": "people/c3914437381388290548",
"etag": "<etag>"
}
]
The birthday field, can take both Date or text, and are not guaranteed to be the same.

Is it possible to make a partial refund multiple times?

Is it possible to make partial refund using Authorize.Net? E.g. I have a transaction by 300$. First time I need to make a refund 100$ on this transaction. And second time to make a refund 50$.
What kind of transaction status will be after that?
first request:
...
"refId": "123456",
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": "100.00",}
"refTransId": "1234567890"
}
...
second request:
...
"refId": "123456",
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": "50.00",}
"refTransId": "1234567890"
}
...
Yes, you can make multiple refunds against one transaction as long as you do not go over the original transaction amount.
Below I made a $50 payment and then following up with a $20 and $10 refund. Both were successful.
Here is my original AUTH_CAPTURE request:
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 38947161,
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": 100,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020",
"cardCode": "999"
}
},
"order": {
"invoiceNumber": "1324567890",
"description": "this is a test transaction"
},
"lineItems": {
"lineItem": [
{
"itemId": "1",
"name": "vase",
"description": "Cannes logo",
"quantity": "18",
"unitPrice": "45.00"
},
{
"itemId": "2",
"name": "desk",
"description": "Big Desk",
"quantity": "10",
"unitPrice": "85.00"
}
]
},
"tax": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"duty": {
"amount": "8.55",
"name": "duty name",
"description": "duty description"
},
"shipping": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"poNumber": "456654",
"customer": {
"id": "18",
"email": "someone#blackhole.tv"
},
"billTo": {
"firstName": "Ellen",
"lastName": "Johnson",
"company": "Souveniropolis",
"address": "14 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"shipTo": {
"firstName": "China",
"lastName": "Bayles",
"company": "Thyme for Tea",
"address": "12 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"customerIP": "192.168.1.1",
"transactionSettings": {
"setting": [
{
"settingName": "allowPartialAuth",
"settingValue": "false"
},
{
"settingName": "duplicateWindow",
"settingValue": "0"
},
{
"settingName": "emailCustomer",
"settingValue": "false"
},
{
"settingName": "recurringBilling",
"settingValue": "false"
},
{
"settingName": "testRequest",
"settingValue": "false"
}
]
},
"userFields": {
"userField": {
"name": "favorite_color",
"value": "blue"
}
}
}
}
}
Here is my original AUTH_CAPTURE response:
{
"transactionResponse": {
"responseCode": "1",
"authCode": "TTJ26B",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "40032153203",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"userFields": [
{
"name": "favorite_color",
"value": "blue"
}
],
"transHashSha2": "0C9E5A47F93CD5B770A6B4AB24FE0F0D6F3B909066C72A10C4746F48C9886527A18B654736AE8D920D9048A14F2823A0DEC5B5F775A1C48DE9CBCF41C8D28CA3",
"SupplementalDataQualificationIndicator": 0
},
"refId": "38947161",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
Here is my first REFUND request (successful):
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 30777668,
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": 20,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020"
}
},
"authCode": "40032153203"
}
}
}
Here is my first REFUND response (successful):
{
"transactionResponse": {
"responseCode": "1",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "40032153314",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "4CE2D83B56C09494AD5609440E3337A6DEE0F4C74FBC99B218D65F6A121EFFC269F8954AC47C17B3B739E61A860C7B0818A8497D85D314D6E0CD89C9FE71A071",
"SupplementalDataQualificationIndicator": 0
},
"refId": "30777668",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
Here is my second REFUND request (successful):
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 40597686,
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": 10,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020"
}
},
"authCode": "40032153203"
}
}
}
Here is my second REFUND response (successful):
{
"transactionResponse": {
"responseCode": "1",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "40032153319",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "FD146FC0F8F3F31068905EC6C8D252662AA735ACDFAC53B4A8D808060C244C06288700AA8872466C3E240B62130D010CFBDE0473D09B631514A6E2E2CB77804F",
"SupplementalDataQualificationIndicator": 0
},
"refId": "40597686",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

How to create payment profile with the create transaction request on Authorize.net

I would like to create the payment profile with the createTransactionRequest.
Here are the request parameters that i am passing.
{
"createTransactionRequest":{
"merchantAuthentication":{
"name":"***",
"transactionKey":"***"
},
"transactionRequest":{
"transactionType":"authCaptureTransaction",
"amount":"4.95",
"payment":{
"creditCard":{
"cardNumber":"5424000000000015",
"expirationDate":"1217",
"cardCode":123
}
},
"billTo":{
"firstName":"first name",
"lastName":"last name",
"address":"test address",
"city":"test city",
"state":"TX",
"zip":"12345",
"country":"USA"
},
"profile":{
"createProfile":true
}
}
}
}
and here is the response error.
{
"messages":{
"resultCode":"Error",
"message":[
{
"code":"E00003",
"text":"The element 'transactionRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'profile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'shipTo, customerIP, cardholderAuthentication, retail, employeeId, transactionSettings, userFields, surcharge, merchantDescriptor, subMerchant, tip' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."
}
]
}
}
The order of the fields in your request matter. They must match what is in the documentation. That means that field needs to come before the billTo field in your JSON:
{
"createTransactionRequest":{
"merchantAuthentication":{
"name":"***",
"transactionKey":"***"
},
"transactionRequest":{
"transactionType":"authCaptureTransaction",
"amount":"4.95",
"payment":{
"creditCard":{
"cardNumber":"5424000000000015",
"expirationDate":"1217",
"cardCode":123
}
},
"profile":{
"createProfile":true
},
"billTo":{
"firstName":"first name",
"lastName":"last name",
"address":"test address",
"city":"test city",
"state":"TX",
"zip":"12345",
"country":"USA"
},
}
}
}
This request yields me this response:
{
"transactionResponse": {
"responseCode": "1",
"authCode": "Y77MQH",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "40007520179",
"refTransID": "",
"transHash": "94D188D090B695D7C6D47D9293840BE3",
"testRequest": "0",
"accountNumber": "XXXX0015",
"accountType": "MasterCard",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "9768048279544EDB22BAAAC194CA3EDBA705FBC569AC9555F3A2A86E545938849CEB2D9519885A4CC69328BBB7DDC36E0852998CAD5FAC1F6CA6427599E3493B"
},
"profileResponse": {
"messages": {
"resultCode": "Error",
"message": [
{
"code": "E00102",
"text": "Customer Info is missing."
}
]
}
},
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
Looks like you need to add the id field in the customer section:
{
"createTransactionRequest":{
"merchantAuthentication":{
"name":"***",
"transactionKey":"***"
},
"transactionRequest":{
"transactionType":"authCaptureTransaction",
"amount":"4.95",
"payment":{
"creditCard":{
"cardNumber":"5424000000000015",
"expirationDate":"1217",
"cardCode":123
}
},
"profile":{
"createProfile":true
},
"customer":{
"id":<yourIdForThisUser>
},
"billTo":{
"firstName":"first name",
"lastName":"last name",
"address":"test address",
"city":"test city",
"state":"TX",
"zip":"12345",
"country":"USA"
},
}
}
}
That yields:
{
"transactionResponse": {
"responseCode": "1",
"authCode": "SCSVNX",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "40007520393",
"refTransID": "",
"transHash": "DFB7FE5B8D3FAFE0A18A6B5C125838A3",
"testRequest": "0",
"accountNumber": "XXXX0015",
"accountType": "MasterCard",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "57C6A161A948E5A7F5303FCD2FE8CDF3E1D3C38B989161675D47FD61526F3DA9EDBD497169F978860B78A2C5FEC1B6E54807086DF4B0CE346538DDDD9E25C4A8"
},
"profileResponse": {
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
},
"customerProfileId": "1502546960",
"customerPaymentProfileIdList": [
"1502081232"
],
"customerShippingAddressIdList": []
},
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

facebook reactions to be grouped by aggs terms elasticsearch

I am working on Facebook analytic, Here is a query which is supposed to fetch the summary of the reactions from Facebook page posts,
Note: posts json is as it is inserted to elastic-search db
{
"query": {
"match": {
"from.id": "[Page-id]"
}
},
"aggs": {
"summary_reaction": {
"terms": {
"field": "reactions.data.type.keyword"
}
}
}
}
Only issue is query return unique count whereas it should consider all reactions.
My result is
"aggregations": {
"reaction_summary": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "LIKE",
"doc_count": 2
},
{
"key": "HAHA",
"doc_count": 1
}
]
}
}
here is the sample json
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 6.158189,
"hits": [
{
"_index": "facebook_page",
"_type": "post",
"_id": "AV1RMRKSSM3OTvGpqzx7",
"_score": 6.158189,
"_source": {
"reactions": {
"paging": {
"cursors": {
"after": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EVTNOREU2TWpVME1EazJNVFl4TXc9PQZDZD",
"before": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EVTNOREU2TWpVME1EazJNVFl4TXc9PQZDZD"
}
},
"data": [
{
"pic_large": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"type": "LIKE",
"id": "116879722275526",
"name": "Moojaa"
}
]
},
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p50x50/20108099_116879808942184_8792637908147052517_n.png?oh=24cc256b24e5da70f306afcf784a636d&oe=59FBA1D4&__gda__=1509895651_44acee6189c7c1cb6eed023a6e742d1a",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"coordinates": {},
"created_time": "2017-07-17T15:35:35+0000",
"message": "Kuthey e Moojaa",
"type": "status",
"id": "116879722275526_116886608941504"
}
},
{
"_index": "facebook_page",
"_type": "post",
"_id": "AV1RMRViSM3OTvGpqzx8",
"_score": 6.158189,
"_source": {
"reactions": {
"paging": {
"cursors": {
"after": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EUTBNRGc2TWpVME1EazJNVFl4TXc9PQZDZD",
"before": "TVRBd01ERTFOREl5TkRrNE56Y3dPakUxTURBek1EUTFNams2TWpVME1EazJNVFl4TXc9PQZDZD"
}
},
"data": [
{
"pic_large": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"type": "LIKE",
"id": "111467022710714",
"name": "Ram Singh Shankar"
},
{
"pic_large": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"type": "LIKE",
"id": "116879722275526",
"name": "Moojaa"
}
]
},
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p50x50/20108099_116879808942184_8792637908147052517_n.png?oh=24cc256b24e5da70f306afcf784a636d&oe=59FBA1D4&__gda__=1509895651_44acee6189c7c1cb6eed023a6e742d1a",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"coordinates": {},
"comments": {
"paging": {
"cursors": {
"after": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE5UUTRPVFF5TURFd09qRTFNREF6TURRMk5Eaz0ZD",
"before": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE5EUXlNamMxTXpVME9qRTFNREF6TURRMk1URT0ZD"
}
},
"data": [
{
"message": "test",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880885608743_116881442275354"
},
{
"message": "test 2",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880885608743_116881548942010"
}
]
},
"created_time": "2017-07-17T15:13:23+0000",
"message": "another Mooja",
"type": "status",
"id": "116879722275526_116880885608743"
}
},
{
"_index": "facebook_page",
"_type": "post",
"_id": "AV1RMRgtSM3OTvGpqzx9",
"_score": 6.158189,
"_source": {
"reactions": {
"paging": {
"cursors": {
"after": "TVRBd01ERTFOREl5TkRrNE56Y3dPakUxTURBek1EUXpPRGM2TnpnNE5qUTRNRE0zT1RFek16RXkZD",
"before": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EUTVOVEk2TnpnNE5qUTRNRE0zT1RFek16RXkZD"
}
},
"data": [
{
"pic_large": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"type": "HAHA",
"id": "116879722275526",
"name": "Moojaa"
},
{
"pic_large": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"type": "HAHA",
"id": "111467022710714",
"name": "Ram Singh Shankar"
}
]
},
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p50x50/20108099_116879808942184_8792637908147052517_n.png?oh=24cc256b24e5da70f306afcf784a636d&oe=59FBA1D4&__gda__=1509895651_44acee6189c7c1cb6eed023a6e742d1a",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"coordinates": {},
"comments": {
"paging": {
"cursors": {
"after": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE9ESTFOakE0TmpRNU9qRTFNREF6TURRM05EYz0ZD",
"before": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE5UVTRPVFF5TURBNU9qRTFNREF6TURRMk5UUT0ZD"
}
},
"data": [
{
"message": "test 3",
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"id": "116880192275479_116881558942009"
},
{
"message": "test ram",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880192275479_116881578942007"
},
{
"message": "test singh",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880192275479_116881598942005"
},
{
"message": "khair",
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"id": "116880192275479_116881825608649"
}
]
},
"created_time": "2017-07-17T15:10:12+0000",
"message": "Testing my Mooja",
"type": "status",
"id": "116879722275526_116880192275479"
}
}
]
}
}
You have to set data inside the reactions as nested type and you can do nested aggregation on the data to get all the counts for the type.
Mappings
PUT facebook_index1
{
"mappings": {
"document_type" : {
"properties": {
"reactions" : {
"type": "object",
"properties": {
"data" : {
"type" : "nested",
"properties" : {
"type" : {
"type" : "keyword"
}
}
}
}
}
}
}
}
}
Query
use nested aggs to aggregate for type for data.
POST facebook_index1/_search
{
"size": 0,
"aggs": {
"nested_data_aggs": {
"nested": {
"path": "reactions.data"
},
"aggs": {
"summary_reaction": {
"terms": {
"field": "reactions.data.type",
"size": 10
}
}
}
}
}
}
Hope this works