How to append/update the objects in a JSON array to another JSON array inside an object - mule

These are my two payloads.I want to add the second payload to first load using DataWave. Someone please help me. I want to add a second payload account to the first account without affecting the remaining data.
payload 1
[
{
"_id" : "7c2a355a-1fca-11ed-861d-0242ac120002",
"accounts" : [
{
//these are some accounts
"account_id" : b206ae7e-1fca-11ed-861d-0242ac120002,
account number : 123456,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 03501efa-1fcb-11ed-861d-0242ac120002,
"model" : car
},
//second account
{
"account_id" : 416535ee-1fcc-11ed-861d-0242ac120002,
account number : 594154,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 416535ee-1fcc-11ed-861d-0242ac120002,
"model" : car
},
//third account
{
"account_id" : 416535ee-1fcc-11ed-861d-0242ac120002,
account number : 258963,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 65736c26-1fcc-11ed-861d-0242ac120002,
"model" : car
},
"related entities" : [
{
"Entity_id" : 8a107a20-1fcb-11ed-861d-0242ac120002,
"shortname" : "name"
"addresses" : [
{
Entity_address_id : ca66ac66-1fcb-11ed-861d-0242ac120002
city : XXX
state : xxx
}
}
]
This is my first payload contains accounts and other information
payload 2 :
{
//first account
"account_id" : 067094ce-1fcc-11ed-861d-0242ac120002,
account number : 464634,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 1c971994-1fcc-11ed-861d-0242ac120002,
"model" : car
},
//second account
{
"account_id" : 24835d3e-1fcc-11ed-861d-0242ac120002,
account number : 14654163,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 03501efa-1fcb-11ed-861d-0242ac120002,
"model" : car
}
final Output :
//this is the final output by combining two payloads
[
{
"_id" : "7c2a355a-1fca-11ed-861d-0242ac120002",
"accounts" : [
{
//first payload
"account_id" : b206ae7e-1fca-11ed-861d-0242ac120002,
account number : 123456,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 03501efa-1fcb-11ed-861d-0242ac120002,
"model" : car
},
//second account
{
"account_id" : 416535ee-1fcc-11ed-861d-0242ac120002,
account number : 594154,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 416535ee-1fcc-11ed-861d-0242ac120002,
"model" : car
},
{
"account_id" : 416535ee-1fcc-11ed-861d-0242ac120002,
account number : 258963,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 65736c26-1fcc-11ed-861d-0242ac120002,
"model" : car
},
{
"account_id" : 067094ce-1fcc-11ed-861d-0242ac120002,
account number : 464634,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 1c971994-1fcc-11ed-861d-0242ac120002,
"model" : car
},
{
"account_id" : 24835d3e-1fcc-11ed-861d-0242ac120002,
account number : 14654163,
current balance : {
$number decimal : "0"
},
daily interest rate : null,
collateral : [
{
"loan collateral id" : 03501efa-1fcb-11ed-861d-0242ac120002,
"model" : car
},
"related entities" : [
{
"Entity_id" : 8a107a20-1fcb-11ed-861d-0242ac120002,
"shortname" : "name"
"addresses" : [
{
Entity_address_id : ca66ac66-1fcb-11ed-861d-0242ac120002
city : XXX
state : xxx
}
}
]
I am getting total 5 accounts in final payload.someone please help me to write the DataWeave code.

Assuming the intention is to concatenate the accounts from payload1 and payload2, and that payload2 is actually an array, then you can just use the update operator. I'm showing a simplified example, which is what is recommended to do for this kind of questions since most of the payload information is not relevant to the answer.
%dw 2.0
output application/json
var payload2=[
{
"account_id" : "067094ce-1fcc-11ed-861d-0242ac120002",
"account number" : 464634
},
{
"account_id" : "24835d3e-1fcc-11ed-861d-0242ac120002",
"account number" : 14654163
}
]
---
payload[0] update {
case accounts at .accounts -> accounts ++ payload2
}
Input payload:
[
{
"_id" : "7c2a355a-1fca-11ed-861d-0242ac120002",
"accounts" : [
{
"account_id" : "b206ae7e-1fca-11ed-861d-0242ac120002",
"account number" : 123456
},
{
"account_id" : "416535ee-1fcc-11ed-861d-0242ac120002",
"account number" : 594154
},
{
"account_id" : "416535ee-1fcc-11ed-861d-0242ac120002",
"account number" : 258963
}
]
}
]
Output:
{
"_id": "7c2a355a-1fca-11ed-861d-0242ac120002",
"accounts": [
{
"account_id": "b206ae7e-1fca-11ed-861d-0242ac120002",
"account number": 123456
},
{
"account_id": "416535ee-1fcc-11ed-861d-0242ac120002",
"account number": 594154
},
{
"account_id": "416535ee-1fcc-11ed-861d-0242ac120002",
"account number": 258963
},
{
"account_id": "067094ce-1fcc-11ed-861d-0242ac120002",
"account number": 464634
},
{
"account_id": "24835d3e-1fcc-11ed-861d-0242ac120002",
"account number": 14654163
}
]
}

Related

How to guarantee air price quote after PNR creation on Sabre API?

I'm trying to create a PNR with "Time to think/Fare lock" option offered by airlines like AF, KLM, LH and more. The idea is to create the PNR to temporarily "block" the price until the time limit is reached (48~72hs) but I don't know how.
I'm able to create the PNR, with CreatePassengerNameRecord, without problems and it returns the retained PriceQuote but the fare is not guaranteed until ticketed and the system will re-price the itinerary with the current fare before ticketing.
Request/response example
CreatePassengerNameRecordRQ
"CreatePassengerNameRecordRQ" : {
"version" : "2.2.0",
"haltOnAirPriceError" : true,
"TravelItineraryAddInfo" : {
"AgencyInfo" : {
"Address" : {
"AddressLine" : "TEST",
"CityName" : "TEST",
"CountryCode" : "FR",
"PostalCode" : "99999",
"StreetNmbr" : "TEST 123"
},
"Ticketing" : {
"PseudoCityCode" : "L4GJ",
"TicketType" : "7TAW"
}
},
"CustomerInfo" : {
"ContactNumbers" : {
"ContactNumber" : [
{
"Phone" : "99999999",
"PhoneUseType" : "A"
}
]
},
"CustLoyalty" : [],
"Email" : [
{
"Address" : "test#gmail.com"
},
{
"Address" : "testRes#gmail.com"
}
],
"PersonName" : [
{
"NameNumber" : "1.1",
"PassengerType" : "ADT",
"GivenName" : "TEST",
"Surname" : "TEST"
}
]
}
},
"AirBook" : {
"HaltOnStatus" : [
{
"Code" : "HL"
},
{
"Code" : "KK"
},
{
"Code" : "LL"
},
{
"Code" : "NN"
},
{
"Code" : "NO"
},
{
"Code" : "UC"
},
{
"Code" : "US"
}
],
"OriginDestinationInformation" : {
"FlightSegment" : [
{
"DepartureDateTime" : "2021-02-17T13:15:00",
"ArrivalDateTime" : "2021-02-17T13:45:00",
"FlightNumber" : "1780",
"NumberInParty" : "1",
"ResBookDesigCode" : "G",
"Status" : "NN",
"DestinationLocation" : {
"LocationCode" : "LHR"
},
"MarketingAirline" : {
"Code" : "AF",
"FlightNumber" : "1780"
},
"OriginLocation" : {
"LocationCode" : "CDG"
}
},
{
"DepartureDateTime" : "2021-02-26T11:30:00",
"ArrivalDateTime" : "2021-02-26T13:50:00",
"FlightNumber" : "1581",
"NumberInParty" : "1",
"ResBookDesigCode" : "X",
"Status" : "NN",
"DestinationLocation" : {
"LocationCode" : "CDG"
},
"MarketingAirline" : {
"Code" : "AF",
"FlightNumber" : "1581"
},
"OriginLocation" : {
"LocationCode" : "LHR"
}
}
]
}
},
"AirPrice" : [
{
"PriceComparison" : {
"AcceptablePriceDecrease" : {
"Amount" : 125.3,
"HaltOnNonAcceptablePrice" : true
},
"AcceptablePriceIncrease" : {
"Amount" : 5,
"HaltOnNonAcceptablePrice" : true
},
"AmountSpecified" : 125.3
},
"PriceRequestInformation" : {
"Retain" : true,
"OptionalQualifiers" : {
"MiscQualifiers" : {
"BaggageAllowance" : []
},
"FOP_Qualifiers" : {
"BasicFOP" : {
"Type" : "CK"
}
},
"PricingQualifiers" : {
"ItineraryOptions" : {
"SegmentSelect" : [
{
"Number" : "1",
"RPH" : "1"
},
{
"Number" : "2",
"RPH" : "2"
}
]
},
"PassengerType" : [
{
"Quantity" : "1",
"Code" : "ADT"
}
],
"SpecificFare" : [
{
"FareBasis" : "GS50OALG",
"RPH" : "1"
},
{
"FareBasis" : "XS50OALG",
"RPH" : "2"
}
]
}
}
}
}
],
"SpecialReqDetails" : {
"SpecialService" : {
"SpecialServiceInfo" : {
"AdvancePassenger" : [],
"SecureFlight" : [
{
"PersonName" : {
"NameNumber" : "1.1",
"DateOfBirth" : "1991-01-13",
"Gender" : "M",
"GivenName" : "TEST",
"Surname" : "TEST"
}
}
],
"Service" : [
{
"SSR_Code" : "CTCM",
"PersonName" : {
"NameNumber" : "1.1"
},
"Text" : "0033142890939"
},
{
"SSR_Code" : "CTCE",
"PersonName" : {
"NameNumber" : "1.1"
},
"Text" : "TEST"
}
]
}
}
},
"PostProcessing" : {
"RedisplayReservation" : {
"waitInterval" : 1000
},
"EndTransaction" : {
"Email" : {
"eTicket" : {
"PDF" : {
"Ind" : false
},
"Ind" : false
},
"Ind" : true
},
"Source" : {
"ReceivedFrom" : "TEST"
}
}
}
}
}
CreatePassengerNameRecordRS (partial)
"CreatePassengerNameRecordRS" : {
"ApplicationResults" : {
"status" : "Complete",
"Success" : [
{
"timeStamp" : "2020-11-19T06:29:15.342-06:00"
}
],
"Warning" : [
{
"type" : "BusinessLogic",
"timeStamp" : "2020-11-19T06:29:14.016-06:00",
"SystemSpecificResults" : [
{
"Message" : [
{
"code" : "WARN.SWS.HOST.WARNING_RESPONSE",
"content" : "EndTransactionLLSRQ: TTY REQ PEND"
}
]
}
]
}
]
},
"ItineraryRef" : {
"ID" : "HOKJCQ"
},
"AirBook" : {
"OriginDestinationOption" : {
"FlightSegment" : [
{
"ArrivalDateTime" : "02-17T13:45",
"DepartureDateTime" : "02-17T13:15",
"eTicket" : true,
"FlightNumber" : "1780",
"NumberInParty" : "001",
"ResBookDesigCode" : "G",
"Status" : "NN",
"DestinationLocation" : {
"LocationCode" : "LHR"
},
"MarketingAirline" : {
"Code" : "AF",
"FlightNumber" : "1780"
},
"OriginLocation" : {
"LocationCode" : "CDG"
}
},
{
"ArrivalDateTime" : "02-26T13:50",
"DepartureDateTime" : "02-26T11:30",
"eTicket" : true,
"FlightNumber" : "1581",
"NumberInParty" : "001",
"ResBookDesigCode" : "X",
"Status" : "NN",
"DestinationLocation" : {
"LocationCode" : "CDG"
},
"MarketingAirline" : {
"Code" : "AF",
"FlightNumber" : "1581"
},
"OriginLocation" : {
"LocationCode" : "LHR"
}
}
]
}
},
"AirPrice" : [
{
"PriceComparison" : {
"AmountReturned" : "125.30",
"AmountSpecified" : "125.3"
},
"PriceQuote" : {
"MiscInformation" : {
"BaggageInfo" : {
"SubCodeProperties" : [
{
"SolutionSequenceNmbr" : 1,
"RPH" : 1,
"AncillaryFeeGroupCode" : "BG",
"CommercialNameofBaggageItemType" : "FREE BAGGAGE ALLOWANCE",
"EMD_Type" : "4",
"ExtendedSubCodeKey" : "0DFAAAF"
},
{
"SolutionSequenceNmbr" : 1,
"RPH" : 2,
"AncillaryFeeGroupCode" : "BG",
"CommercialNameofBaggageItemType" : "UPTO50LB 23KG AND62LI 158LCM",
"DescriptionOne" : {
"Code" : "23",
"Text" : "UP TO 50 POUNDS/23 KILOGRAMS"
},
"DescriptionTwo" : {
"Code" : "6U",
"Text" : "UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS"
},
"EMD_Type" : "4",
"ExtendedSubCodeKey" : "0GOACAF",
"SizeWeightInfo" : {
"MaximumSizeInAlternate" : {
"Units" : "C",
"content" : "158"
},
"MaximumSize" : {
"Units" : "I",
"content" : "62"
},
"MaximumWeightInAlternate" : {
"Units" : "K",
"content" : "23"
},
"MaximumWeight" : {
"Units" : "L",
"content" : "50"
}
}
},
{
"SolutionSequenceNmbr" : 1,
"RPH" : 3,
"AncillaryFeeGroupCode" : "BG",
"AncillaryService" : {
"SubGroupCode" : "CY",
"Text" : "CARRY ON HAND BAGGAGE"
},
"CommercialNameofBaggageItemType" : "CARRYON HAND BAGGAGE ALLOWANCE",
"EMD_Type" : "4",
"ExtendedSubCodeKey" : "0LNABAF"
},
{
"SolutionSequenceNmbr" : 1,
"RPH" : 4,
"AncillaryFeeGroupCode" : "BG",
"AncillaryService" : {
"SubGroupCode" : "CY",
"Text" : "CARRY ON HAND BAGGAGE"
},
"BookingMethod" : "04",
"CommercialNameofBaggageItemType" : "CABIN BAGGAGE 12KG 1PC 115CM",
"DescriptionOne" : {
"Code" : "12",
"Text" : "UP TO 26 POUNDS/12 KILOGRAMS"
},
"DescriptionTwo" : {
"Code" : "4U",
"Text" : "UP TO 45 LINEAR INCHES/115 LINEAR CENTIMETERS"
},
"EMD_Type" : "4",
"ExtendedSubCodeKey" : "0MRACAF",
"SizeWeightInfo" : {
"MaximumSizeInAlternate" : {
"Units" : "C",
"content" : "115"
},
"MaximumSize" : {
"Units" : "I",
"content" : "45"
},
"MaximumWeightInAlternate" : {
"Units" : "K",
"content" : "12"
},
"MaximumWeight" : {
"Units" : "L",
"content" : "26"
}
}
}
]
},
"HeaderInformation" : [
{
"SolutionSequenceNmbr" : "1",
"DepartureDate" : "2021-02-17",
"Text" : [
"VALIDATING CARRIER - AF",
"CAT 15 SALES RESTRICTIONS FREE TEXT FOUND - VERIFY RULES",
"BAG ALLOWANCE -CDGLHR-NIL/AF",
"1STCHECKED BAG FEE-CDGLHR-EUR45.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"2NDCHECKED BAG FEE-CDGLHR-EUR70.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"BAG ALLOWANCE -LHRCDG-NIL/AF",
"1STCHECKED BAG FEE-LHRCDG-EUR45.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"2NDCHECKED BAG FEE-LHRCDG-EUR70.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"CARRY ON ALLOWANCE",
"CDGLHR LHRCDG-01P/AF",
"01/UP TO 26 POUNDS/12 KILOGRAMS AND UP TO 45 LINEAR INCHES/115",
"LINEAR CENTIMETERS",
"CARRY ON CHARGES",
"CDGLHR LHRCDG-AF-CARRY ON FEES UNKNOWN-CONTACT CARRIER",
"ADDITIONAL ALLOWANCES AND/OR DISCOUNTS MAY APPLY DEPENDING ON",
"FLYER-SPECIFIC FACTORS /E.G. FREQUENT FLYER STATUS/MILITARY/",
"CREDIT CARD FORM OF PAYMENT/EARLY PURCHASE OVER INTERNET,ETC./"
],
"ValidatingCarrier" : {
"Code" : "AF"
}
}
],
"SolutionInformation" : [
{
"SolutionSequenceNmbr" : "1",
"BaseFareCurrencyCode" : "EUR",
"CurrencyCode" : "EUR",
"GrandTotalEquivFareAmount" : "34.00",
"GrandTotalTaxes" : "91.30",
"RequiresRebook" : "false",
"TicketNumber" : "0",
"TotalAmount" : "125.30"
}
],
"ValidatingCarrier" : [
{
"NewValidatingProcess" : true,
"SolutionSequenceNmbr" : "1",
"SettlementMethod" : "BSP",
"Ticket" : [
{
"Type" : "ETKTREQ",
"CarrierCode" : "AF",
"ValidatingCarrierType" : "Default"
}
]
}
]
},
"PricedItinerary" : {
"AlternativePricing" : "false",
"CurrencyCode" : "EUR",
"MultiTicket" : false,
"TotalAmount" : "125.30",
"AirItineraryPricingInfo" : [
{
"SolutionSequenceNmbr" : "1",
"BaggageProvisions" : [
...
],
"FareCalculation" : {
"Text" : "PAR AF LON17.62AF PAR22.33NUC39.95END ROE0.85086"
},
"FareCalculationBreakdown" : [
{
"Branch" : {
"PCC" : "N1GJ",
"FirstJointCarrier" : "AF"
},
"Departure" : {
"CityCode" : "PAR",
"AirportCode" : "CDG",
"AirlineCode" : "AF",
"GenericInd" : "O",
"ArrivalCityCode" : "LON",
"ArrivalAirportCode" : "LHR"
},
"FareBasis" : {
"Code" : "GS50OALG",
"FareAmount" : "17.62",
"FarePassengerType" : "ADT",
"FareType" : "P",
"FilingCarrier" : "AF",
"GlobalInd" : "EH",
"TripTypeInd" : "R",
"Market" : "PARLON",
"Cabin" : "Y"
},
"FreeBaggageAllowance" : "NONIL",
"RuleCategoryIndicator" : [
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"15",
"16"
]
},
{
"Branch" : {
"PCC" : "N1GJ",
"FirstJointCarrier" : "AF"
},
"Departure" : {
"CityCode" : "LON",
"AirportCode" : "LHR",
"AirlineCode" : "AF",
"GenericInd" : "O",
"ArrivalCityCode" : "PAR",
"ArrivalAirportCode" : "CDG"
},
"FareBasis" : {
"Code" : "XS50OALG",
"FareAmount" : "22.33",
"FarePassengerType" : "ADT",
"FareType" : "P",
"FilingCarrier" : "AF",
"GlobalInd" : "EH",
"TripTypeInd" : "R",
"Market" : "PARLON",
"Cabin" : "Y"
},
"FreeBaggageAllowance" : "NONIL",
"RuleCategoryIndicator" : [
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"15",
"16"
]
}
],
"ItinTotalFare" : {
"NonRefundableInd" : "N",
"BaggageInfo" : {
"NonUS_DOT_Disclosure" : {
"Text" : [
"BAG ALLOWANCE -CDGLHR-NIL/AF",
"1STCHECKED BAG FEE-CDGLHR-EUR45.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"2NDCHECKED BAG FEE-CDGLHR-EUR70.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"BAG ALLOWANCE -LHRCDG-NIL/AF",
"1STCHECKED BAG FEE-LHRCDG-EUR45.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"2NDCHECKED BAG FEE-LHRCDG-EUR70.00/AF/UP TO 50 POUNDS/23 KILOGR",
"AMS AND UP TO 62 LINEAR INCHES/158 LINEAR CENTIMETERS",
"CARRY ON ALLOWANCE",
"CDGLHR LHRCDG-01P/AF",
"01/UP TO 26 POUNDS/12 KILOGRAMS AND UP TO 45 LINEAR INCHES/115",
"LINEAR CENTIMETERS",
"CARRY ON CHARGES",
"CDGLHR LHRCDG-AF-CARRY ON FEES UNKNOWN-CONTACT CARRIER",
"ADDITIONAL ALLOWANCES AND/OR DISCOUNTS MAY APPLY DEPENDING ON",
"FLYER-SPECIFIC FACTORS /E.G. FREQUENT FLYER STATUS/MILITARY/",
"CREDIT CARD FORM OF PAYMENT/EARLY PURCHASE OVER INTERNET,ETC./"
]
}
},
"BaseFare" : {
"Amount" : "34.00",
"CurrencyCode" : "EUR"
},
"Construction" : {
"Amount" : "39.95",
"CurrencyCode" : "NUC",
"RateOfExchange" : "0.850860"
},
"Taxes" : {
"TotalAmount" : "91.30",
"Tax" : [
{
"Amount" : "26.00",
"TaxCode" : "YQI",
"TaxName" : "SERVICE FEE - CARRIER-IMPOSED",
"TicketingTaxCode" : "YQ"
},
{
"Amount" : "16.33",
"TaxCode" : "FR",
"TaxName" : "CIVIL AVIATION TAX DOMESTIC AN",
"TicketingTaxCode" : "FR"
},
{
"Amount" : "13.09",
"TaxCode" : "QX",
"TaxName" : "PASSENGER SERVICE CHARGE INTER",
"TicketingTaxCode" : "QX"
},
{
"Amount" : "1.13",
"TaxCode" : "IZ",
"TaxName" : "AIR PASSENGER SOLIDARITY TAX",
"TicketingTaxCode" : "IZ"
},
{
"Amount" : "14.51",
"TaxCode" : "GB",
"TaxName" : "AIR PASSENGER DUTY APD",
"TicketingTaxCode" : "GB"
},
{
"Amount" : "18.74",
"TaxCode" : "UB",
"TaxName" : "PASSENGER SERVICE CHARGE DEPAR",
"TicketingTaxCode" : "UB"
},
{
"Amount" : "1.50",
"TaxCode" : "O4",
"TaxName" : "AIR PASSENGER SOLIDARITY TAX S",
"TicketingTaxCode" : "O4"
}
]
},
"TotalFare" : {
"Amount" : "125.30",
"CurrencyCode" : "EUR"
}
},
"PassengerTypeQuantity" : {
"Code" : "ADT",
"Quantity" : "1"
},
"PTC_FareBreakdown" : [
{
"Cabin" : "Y",
"FareBasis" : {
"Code" : "GS50OALG",
"FareAmount" : "17.62",
"FarePassengerType" : "ADT",
"FareType" : "P",
"FilingCarrier" : "AF",
"GlobalInd" : "EH",
"Market" : "PARLON"
},
"FreeBaggageAllowance" : "NONIL"
},
{
"Cabin" : "Y",
"FareBasis" : {
"Code" : "XS50OALG",
"FareAmount" : "22.33",
"FarePassengerType" : "ADT",
"FareType" : "P",
"FilingCarrier" : "AF",
"GlobalInd" : "EH",
"Market" : "PARLON"
},
"FreeBaggageAllowance" : "NONIL"
}
]
}
]
}
}
}
],
"TravelItineraryRead" : {
"TravelItinerary" : {
"CustomerInfo" : {
...
},
"ItineraryInfo" : {
"ItineraryPricing" : {
"PriceQuote" : [
{
"RPH" : "1",
"MiscInformation" : {
"SignatureLine" : [
{
"ExpirationDateTime" : "00:00",
"Source" : "SYS",
"Status" : "ACTIVE",
"Text" : "N1GJ N1GJ*AWS 1329/19NOV20"
}
]
},
"PricedItinerary" : [
{
"DisplayOnly" : false,
"InputMessage" : "WPFCK¥S1*ZZGS50OALG¥S2*ZZXS50OALG¥P1ADT¥RQ",
"RPH" : "1",
"StatusCode" : "A",
"TaxExempt" : false,
"ValidatingCarrier" : "AF",
"StoredDateTime" : "2020-11-19T13:29",
"AirItineraryPricingInfo" : {
"ItinTotalFare" : [
{
"BaseFare" : {
"Amount" : "34.00",
"CurrencyCode" : "EUR"
},
"Taxes" : {
"Tax" : {
"Amount" : "91.30",
"TaxCode" : "XT"
},
"TaxBreakdownCode" : [
{
"TaxPaid" : false,
"content" : "26.00YQ"
},
{
"TaxPaid" : false,
"content" : "16.33FR"
},
{
"TaxPaid" : false,
"content" : "13.09QX"
},
{
"TaxPaid" : false,
"content" : "1.13IZ"
},
{
"TaxPaid" : false,
"content" : "14.51GB"
},
{
"TaxPaid" : false,
"content" : "18.74UB"
},
{
"TaxPaid" : false,
"content" : "1.50O4"
}
]
},
"TotalFare" : {
"Amount" : "125.30",
"CurrencyCode" : "EUR"
},
"Totals" : {
"BaseFare" : {
"Amount" : "34.00"
},
"Taxes" : {
"Tax" : {
"Amount" : "91.30"
}
},
"TotalFare" : {
"Amount" : "125.30"
}
}
}
],
"PassengerTypeQuantity" : [
{
"Code" : "ADT",
"Quantity" : "01"
}
],
"PTC_FareBreakdown" : [
{
"Endorsements" : {
"Endorsement" : [
{
"type" : "PRICING_PARAMETER",
"Text" : "WPFCK$S1*ZZGS50OALG$S2*ZZXS50OALG$P1ADT$RQ"
},
{
"type" : "WARNING",
"Text" : "VALIDATING CARRIER - AF"
},
{
"type" : "WARNING",
"Text" : "CAT 15 SALES RESTRICTIONS FREE TEXT FOUND - VERIFY RULES"
}
]
},
"FareBasis" : [
{
"Code" : "GS50OALG/XS50OALG"
}
],
"FareCalculation" : {
"Text" : [
"PAR AF LON17.62AF PAR22.33NUC39.95END ROE0.85086"
]
},
"FareSource" : "ATPC",
"FlightSegment" : [
{
"ConnectionInd" : "O",
"DepartureDateTime" : "02-17T13:15",
"FlightNumber" : "1780",
"ResBookDesigCode" : "G",
"SegmentNumber" : "1",
"Status" : "OK",
"BaggageAllowance" : {
"Number" : "NIL"
},
"FareBasis" : {
"Code" : "GS50OALG"
},
"MarketingAirline" : {
"Code" : "AF",
"FlightNumber" : "1780"
},
"OriginLocation" : {
"LocationCode" : "CDG"
},
"ValidityDates" : {
"NotValidAfter" : "2021-02-17",
"NotValidBefore" : "2021-02-17"
}
},
{
"ConnectionInd" : "O",
"DepartureDateTime" : "02-26T11:30",
"FlightNumber" : "1581",
"ResBookDesigCode" : "X",
"SegmentNumber" : "2",
"Status" : "OK",
"BaggageAllowance" : {
"Number" : "NIL"
},
"FareBasis" : {
"Code" : "XS50OALG"
},
"MarketingAirline" : {
"Code" : "AF",
"FlightNumber" : "1581"
},
"OriginLocation" : {
"LocationCode" : "LHR"
},
"ValidityDates" : {
"NotValidAfter" : "2021-02-26",
"NotValidBefore" : "2021-02-26"
}
},
{
"OriginLocation" : {
"LocationCode" : "CDG"
}
}
],
"FareComponent" : [
{
"FareBasisCode" : "GS50OALG",
"FareDirectionality" : "FROM",
"Amount" : "1762",
"TicketDesignator" : "",
"GoverningCarrier" : "AF",
"FareComponentNumber" : "1",
"Location" : {
"Origin" : "PAR",
"Destination" : "LON"
},
"Dates" : {
"DepartureDateTime" : "02-17T13:15",
"ArrivalDateTime" : "02-17T13:45"
},
"FlightSegmentNumbers" : {
"FlightSegmentNumber" : [
"1"
]
}
},
{
"FareBasisCode" : "XS50OALG",
"FareDirectionality" : "TO",
"Amount" : "2233",
"TicketDesignator" : "",
"GoverningCarrier" : "AF",
"FareComponentNumber" : "2",
"Location" : {
"Origin" : "LON",
"Destination" : "PAR"
},
"Dates" : {
"DepartureDateTime" : "02-26T11:30",
"ArrivalDateTime" : "02-26T13:50"
},
"FlightSegmentNumbers" : {
"FlightSegmentNumber" : [
"2"
]
}
}
]
}
]
}
}
],
"ResponseHeader" : {
"Text" : [
"FARE - PRICE RETAINED",
"FARE USED TO CALCULATE DISCOUNT",
"FARE NOT GUARANTEED UNTIL TICKETED"
]
},
"PriceQuotePlus" : {
"DomesticIntlInd" : "I",
"PricingStatus" : "S",
"VerifyFareCalc" : false,
"ItineraryChanged" : false,
"ManualFare" : false,
"NegotiatedFare" : false,
"SystemIndicator" : "S",
"NUCSuppresion" : false,
"SubjToGovtApproval" : false,
"IT_BT_Fare" : "BT",
"DisplayOnly" : false,
"DiscountAmount" : "0",
"PassengerInfo" : {
"PassengerType" : "ADT",
"PassengerData" : [
{
"NameNumber" : "01.01",
"content" : "TEST/TEST"
}
]
},
"TicketingInstructionsInfo" : {}
}
}
],
"PriceQuoteTotals" : {
"BaseFare" : {
"Amount" : "34.00"
},
"Taxes" : {
"Tax" : {
"Amount" : "91.30"
}
},
"TotalFare" : {
"Amount" : "125.30"
}
}
},
"Ticketing" : [
{
"RPH" : "01",
"TicketTimeLimit" : "TAWL4GJ19NOV009/"
}
]
},
"ItineraryRef" : {
...
},
"SpecialServiceInfo" : [
{
"RPH" : "001",
"Type" : "GFX",
"Id" : "14",
"Service" : {
"SSR_Code" : "SSR",
"SSR_Type" : "DOCS",
"Airline" : {
"Code" : "AF"
},
"PersonName" : [
{
"NameNumber" : "01.01",
"content" : "TEST/TEST"
}
],
"Text" : [
"HK1/DB/13JAN1991/M/TEST/TEST"
]
}
},
{
"RPH" : "002",
"Type" : "GFX",
"Id" : "15",
"Service" : {
"SSR_Code" : "SSR",
"SSR_Type" : "CTCM",
"Airline" : {
"Code" : "AF"
},
"PersonName" : [
{
"NameNumber" : "01.01",
"content" : "TEST/TEST"
}
],
"Text" : [
"HK1/0033142890939"
]
}
},
{
"RPH" : "003",
"Type" : "GFX",
"Id" : "16",
"Service" : {
"SSR_Code" : "SSR",
"SSR_Type" : "CTCE",
"Airline" : {
"Code" : "AF"
},
"PersonName" : [
{
"NameNumber" : "01.01",
"content" : "TEST/TEST"
}
],
"Text" : [
"TEST"
]
}
}
]
}
}
}
Do I need to specify something in CreatePassengerNameRecordRQ to freeze the fare quote ?
Is there any other action needed to access this special option offered by some airlines ?
Thank you !

How to get last second of every minute from mongoDB using SQL query

I have a table with records for every millisecond. I need to get only the last second of every minute using Mongodb sql query.
Id Balance DataTime
1 "2462188.61" 2019-09-27T05:49:33.575+00:00
1 "2449426.30" 2019-10-30T19:30:52.513+00:00
1 "2456459.67" 2019-10-15T18:20:09.490+00:00
5 "1006266.91" 2019-10-31T13:48:18.290+00:00
I tried the LIKE condition but that didn't work.
Select Id, DateTime,Balance from AccountBalance where DateTime like '%59.000%'
Here is the link for the mongoldb SQL reference :
https://docs.mongodb.com/bi-connector/current/supported-operations/
I am using the BI connector to connect to Tableau(hence need the sql version of the query)
Thanks in advance!
You could try...
db.z.aggregate([
{ $addFields: {
year: { $dateToString: { format: "%Y", date: "$DataTime" } },
month: { $dateToString: { format: "%m", date: "$DataTime" } },
day: { $dateToString: { format: "%d", date: "$DataTime" } },
hour: { $dateToString: { format: "%H", date: "$DataTime" } },
minute: { $dateToString: { format: "%M", date: "$DataTime" } },
second: { $dateToString: { format: "%S", date: "$DataTime" } }
}
}
]).pretty()
This assumes your field DataTime is of type ISODate()...
Example Documents:
{ "_id" : ObjectId("5dea94c3b4ae6bbc17cd023b"), "Balance" : "2462188.61", "DataTime" : ISODate("2019-09-27T05:49:33.575Z") }
{ "_id" : ObjectId("5dea94c3b4ae6bbc17cd023c"), "Balance" : "2449426.30", "DataTime" : ISODate("2019-10-30T19:30:52.513Z") }
{ "_id" : ObjectId("5dea94c3b4ae6bbc17cd023d"), "Balance" : "2456459.67", "DataTime" : ISODate("2019-10-15T18:20:09.490Z") }
{ "_id" : ObjectId("5dea94c3b4ae6bbc17cd023e"), "Balance" : "1006266.91", "DataTime" : ISODate("2019-10-31T13:48:18.290Z") }
Example Query Output:
{
"_id" : ObjectId("5dea94c3b4ae6bbc17cd023b"),
"Balance" : "2462188.61",
"DataTime" : ISODate("2019-09-27T05:49:33.575Z"),
"year" : "2019",
"month" : "09",
"day" : "27",
"hour" : "05",
"minute" : "49",
"second" : "33"
}
{
"_id" : ObjectId("5dea94c3b4ae6bbc17cd023c"),
"Balance" : "2449426.30",
"DataTime" : ISODate("2019-10-30T19:30:52.513Z"),
"year" : "2019",
"month" : "10",
"day" : "30",
"hour" : "19",
"minute" : "30",
"second" : "52"
}
{
"_id" : ObjectId("5dea94c3b4ae6bbc17cd023d"),
"Balance" : "2456459.67",
"DataTime" : ISODate("2019-10-15T18:20:09.490Z"),
"year" : "2019",
"month" : "10",
"day" : "15",
"hour" : "18",
"minute" : "20",
"second" : "09"
}
{
"_id" : ObjectId("5dea94c3b4ae6bbc17cd023e"),
"Balance" : "1006266.91",
"DataTime" : ISODate("2019-10-31T13:48:18.290Z"),
"year" : "2019",
"month" : "10",
"day" : "31",
"hour" : "13",
"minute" : "48",
"second" : "18"
}
use sort function with date
eg:
db.collection.find().sort("Date_Field")

i want to query the double nested dates in mongodb

----------Query i have tried----------
db.getCollection('rates').aggregate([
{ $match: { "userId" : "5d4c4f69341b7b1746c80d13"}},
{ $unwind: '$ratewithdate.daywiserates'},{$match : {"$and" :
[{"ratewithdate.daywiserates.date" :{$gte :new ISODate("2019-09-
23T00:00:00.000Z")} },
{"ratewithdate.daywiserates.date" :{$lte :new ISODate("2019-09-
27T00:00:00.000Z")}}]}}])
-------------------------------------------------------------
In My query is here i want to know the query between two dates ,i want
get the data between two dates in the array? am unable to do that ,can
any one send me query,
here my question is i want get the date range from given date to next 30
days,i have tried with aggregate but data become slow..can any one suggest
any better solution for the making query formation
i have tried with aggregation as well find queries am not able find any
results,my goal here is find get the data between two dates,for example
if i selected 2019-09-23T10:43:14.239Z thi date from this date i wanna i
want to show the data.
please send me your value able suggestions to, am not bale to query with
double nested array queries in mongodb,please send me your value able
suggestions to,am not bale to query with double nested array queries in
mongodb please send me your value able suggestions to,
am not bale to query with double nested array queries in mongodb.
please send me your value able suggestions to, am not bale to query with
double nested array queries in mongodb,please send me your value able
suggestions to,am not bale to query with double nested array queries in
mongodb please send me your value able suggestions to,
am not bale to query with double nested array queries in mongodb
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1bff"),
"alloted_roomid" : [],
"name" : "working_rate3",
"description" : "bitcpin",
"type" : "room",
"value" : null,
"inclusive" : "General",
"refundable" : {
"cancellationWindow" : "",
"outsideWindowPenalty" : "",
"insideWindowPenalty" : ""
},
"nonRefundable" : true,
"cancellationWindow" : "",
"daysWiseRate" : "30",
"insideWindowPenalty" : "",
"outsideWindowPenalty" : "",
"deviations" : 980,
"policy" : "",
"funds" : "nonRefundable",
"vat" : 890,
"other_tax" : 90,
"roomRates" : [
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c00"),
"roomId" : ObjectId("5d7c8f2950a6c766c64b2a46"),
"roomName" : "Basic",
"rate" : 9888
}
],
"userId" : "5d4c4f69341b7b1746c80d13",
"hotelCode" : 10034,
"ratewithdate" : [
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c01"),
"roomCategory" : "Basic",
"roomId" : ObjectId("5d7c8f2950a6c766c64b2a46"),
"createdAt" : ISODate("2019-09-21T10:43:14.243Z"),
"daywiserates" : [
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c1f"),
"date" : ISODate("2019-09-21T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c1e"),
"date" : ISODate("2019-09-22T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c1d"),
"date" : ISODate("2019-09-23T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c1c"),
"date" : ISODate("2019-09-24T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c1b"),
"date" : ISODate("2019-09-25T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c1a"),
"date" : ISODate("2019-09-26T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c19"),
"date" : ISODate("2019-09-27T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c18"),
"date" : ISODate("2019-09-28T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c17"),
"date" : ISODate("2019-09-29T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c16"),
"date" : ISODate("2019-09-30T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c15"),
"date" : ISODate("2019-10-01T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c14"),
"date" : ISODate("2019-10-02T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c13"),
"date" : ISODate("2019-10-03T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c12"),
"date" : ISODate("2019-10-04T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c11"),
"date" : ISODate("2019-10-05T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c10"),
"date" : ISODate("2019-10-06T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c0f"),
"date" : ISODate("2019-10-07T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c0e"),
"date" : ISODate("2019-10-08T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c0d"),
"date" : ISODate("2019-10-09T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c0c"),
"date" : ISODate("2019-10-10T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c0b"),
"date" : ISODate("2019-10-11T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c0a"),
"date" : ISODate("2019-10-12T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c09"),
"date" : ISODate("2019-10-13T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c08"),
"date" : ISODate("2019-10-14T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c07"),
"date" : ISODate("2019-10-15T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c06"),
"date" : ISODate("2019-10-16T10:43:14.239Z"),
"rate" : 9888
},
{
"_id" : ObjectId("5d85fec2e8652a5c20ae1c05"),
"date" : ISODate("2019-10-17T10:43:14.239Z"),
"rate" : 9888
},
]
}
],
"id" : "rat-W262IxTjk",
"__v" : 0
}
Try this:
db.getCollection('rates').aggregate([
{ $match: { "userId" : "5d4c4f69341b7b1746c80d13"}},
{ $unwind: '$ratewithdate'},
{ $unwind: '$ratewithdate.daywiserates'},
{ $match : {
"$and" :[
{ "ratewithdate.daywiserates.date" :{$gte :new ISODate("2019-09-23T00:00:00.000Z")} },
{ "ratewithdate.daywiserates.date" :{$lte :new ISODate("2019-09-27T00:00:00.000Z")} }
]
}
},
{ $addFields: {result: "$ratewithdate.daywiserates"}},
{ $project: {result: 1, _id: 0}}
])

db.find vs db.aggregation to select nested array Object

I'v tried to perform the following query :
db.getCollection('fxh').find({"username": "user1", "pf.acc.accnbr" : 915177},{userid: true, "pf.pfid": true, "pf.acc.accid":true})
and my collection is the following :
{
"_id" : ObjectId("5932fd8f381d4c0a7de21942"),
"userid" : 1496513894,
"username" : "user1",
"email" : "user1#gmail.com",
"fullname" : "User 1",
"pf" : {
"acc" : [
{
"cyc" : [
{
"det" : {
"status" : "New",
"dcycid" : 1496513941
},
"status" : "New",
"name" : "QPT202017_M1",
"cycid" : 1496513940
}
],
"status" : "New",
"accnbr" : 915177,
"accid" : 1496513939
},
{
"cyc" : [
{
"det" : {
"status" : "New",
"dcycid" : 1496552643
},
"status" : "New",
"name" : "QPT202017_S8",
"cycid" : 1496552642
}
],
"status" : "New",
"accnbr" : 73497,
"accid" : 1496552641
}
],
"pfid" : 1496513935,
},
"lastupdate" : ISODate("2017-06-03T18:18:55.080Z"),
"__v" : 0
}
When I execute the query the result is the following :
{
"_id" : ObjectId("5932fd8f381d4c0a7de21942"),
"userid" : 1496513894,
"portfolio" : {
"acc" : [
{
"accid" : 1496513939
},
{
"accid" : 1496552641
}
],
"pfid" : 1496513935
}
}
And my problem is that I need to see only the concerned accid and the result returns the all accid !.
Any idea how just to return the selected accid of accnbr ?
NB : I have also tried to add $ sign at the end of my query , it
selects the right acc but it returns the all objects or I need just
only ONE returned object.
On 6/5/17
I also used the aggregate command instead of find and it get result by using this :
db.getCollection('fxh').aggregate([ { $unwind : "$pf.acc"} , { $match : {"username":"adh1", "pf.acc.accbr": 915177 } }, {$project : {_id:0, accid: "$pf.acc.accid"}}])
But could NOT get a lower level result, when I ran this :
db.getCollection('fxh').aggregate([ { $unwind : "$pf.acc.cyc"} , { $match : {"username":"adh1", "pf.acc.accbr": 915177, "pf.acc.cyc.name": "QPT202017_M1" } }, {$project : {_id:0, cycid: "$pf.acc.cyc.cycid"}}])
Any idea ?
You can try the below aggregation pipeline.
The idea is to $unwind one nested level at a time, starting from the outermost to the innermost.
For each nested level unwinding, you can apply the$match to limit the documents and continue till you have the desired shape.
You can $group it together at the end to get back to the original shape.
db.getCollection('fxh').aggregate([
{ $match : {"username":"adh1"} },
{ $unwind : "$pf.acc"} ,
{ $match : {"pf.acc.accbr": 915177 } },
{ $unwind : "$pf.acc.cyc"},
{ $match : {"pf.acc.cyc.name": "QPT202017_M1" } },
{$project : {_id:0, accid: "$pf.acc.accid", cycid: "$pf.acc.cyc.cycid"}}])

Scoring documents in Lucene 6.2.0

My query in lucene 6.2.0 goes like:
query query = new PhraseQuery.Builder()
.add(new Term("country","russia"))
.setSlop(1)
.build();
Basically among all my documents which are:
{
"_id" : ObjectId("586b723b4b9a835db416fa26"),
"name" : "test",
"countries" : {
"country" : [
{
"name" : "russia"
},
{
"name" : "USA china"
}
]
}
}
{
"_id" : ObjectId("586b73f24b9a835fefb10ca5"),
"name" : "nitika jain",
"countries" : {
"country" : [
{
"name" : "russia and denmrk"
},
{
"name" : "USA china"
}
]
}
}
{
"_id" : ObjectId("586b744f4b9a835fefb10ca7"),
"name" : "arjun",
"countries" : {
"country" : [
{
"name" : "russia pakistan"
},
{
"name" : "india iraq"
}
]
}
}
I want a document which has only russia. Ideally it should be the one highest scored, but instead I get something like "Found 3 hits."
Document<stored,indexed,tokenized<id:586b723b4b9a835db416fa26> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<name:test> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<countries:{ "country" : [ { "name" : "russia"} , { "name" : "USA china"}]}> stored,indexed,tokenized<country:russia> stored,indexed,tokenized<country:USA china>>**0.12874341**
Document<stored,indexed,tokenized<id:586b73f24b9a835fefb10ca5> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<name:nitika jain> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<countries:{ "country" : [ { "name" : "russia and denmrk"} , { "name" : "USA china"}]}> stored,indexed,tokenized<country:russia and denmrk> stored,indexed,tokenized<country:USA china>>**0.12874341**
Document<stored,indexed,tokenized<id:586b744f4b9a835fefb10ca7> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<name:arjun> stored,indexed,tokenized,omitNorms,indexOptions=DOCS<countries:{ "country" : [ { "name" : "russia pakistan"} , { "name" : "india iraq"}]}> stored,indexed,tokenized<country:russia pakistan> stored,indexed,tokenized<country:india iraq>>**0.12874341**
All 3 results are equally scored. How can I get the document with only russia to be highest scored?
In Phrase queries, the slop is zero by default, requiring exact matches. that means that if you modify your query in this way:
query query = new PhraseQuery.Builder()
.add(new Term("country","russia"))
.build();
you'll get what you're looking for.