I am trying to use Postman to make a POST request to the Magento API and I am getting back an error message that says:
{"message":"Unable to save product"}.
Here is the code I am running through Postman.
{
"product":{"sku": "123456","name": "New Shoe","attribute_set_id": 11,"price": "status": "visibility": "type_id": ""created_at": "2016-12-04 15:03:"updated_at": "2016-12-04 15:03:"}
I am running it through a POST request under the /V1/products/ directory. I am able to Get information from the API with the access key I am using so I do not believe that it is an Authorization issue.
I have tried doing the same request changing some of the information using PUT and I am getting the same result. Any suggestions or thoughts would be greatly appreciated!
You can open Magento2 source code, try to find this file vendor/magento/module-catalog/Model/ProductRepository.php:732
Change last catch to this:
catch (\Exception $e) {
echo $e->getMessage();
die();
throw new CouldNotSaveException(__('Unable to save product'), $e);
}
You will see what your problem is. Example:
show exception message
catalogProductRepositoryV1
POST /V1/products
Create product
Body > Data
{
"product": {
"id": 0,
"sku": "string",
"name": "string",
"attributeSetId": 0,
"price": 0,
"status": 0,
"visibility": 0,
"typeId": "string",
"createdAt": "string",
"updatedAt": "string",
"weight": 0,
"extensionAttributes": {
"downloadableProductLinks": [
{
"id": 0,
"title": "string",
"sortOrder": 0,
"isShareable": 0,
"price": 0,
"numberOfDownloads": 0,
"linkType": "string",
"linkFile": "string",
"linkFileContent": {
"fileData": "string",
"name": "string",
"extensionAttributes": {}
},
"linkUrl": "string",
"sampleType": "string",
"sampleFile": "string",
"sampleFileContent": {
"fileData": "string",
"name": "string",
"extensionAttributes": {}
},
"sampleUrl": "string",
"extensionAttributes": {}
}
],
"downloadableProductSamples": [
{
"id": 0,
"title": "string",
"sortOrder": 0,
"sampleType": "string",
"sampleFile": "string",
"sampleFileContent": {
"fileData": "string",
"name": "string",
"extensionAttributes": {}
},
"sampleUrl": "string",
"extensionAttributes": {}
}
],
"stockItem": {
"itemId": 0,
"productId": 0,
"stockId": 0,
"qty": 0,
"isInStock": true,
"isQtyDecimal": true,
"showDefaultNotificationMessage": true,
"useConfigMinQty": true,
"minQty": 0,
"useConfigMinSaleQty": 0,
"minSaleQty": 0,
"useConfigMaxSaleQty": true,
"maxSaleQty": 0,
"useConfigBackorders": true,
"backorders": 0,
"useConfigNotifyStockQty": true,
"notifyStockQty": 0,
"useConfigQtyIncrements": true,
"qtyIncrements": 0,
"useConfigEnableQtyInc": true,
"enableQtyIncrements": true,
"useConfigManageStock": true,
"manageStock": true,
"lowStockDate": "string",
"isDecimalDivided": true,
"stockStatusChangedAuto": 0,
"extensionAttributes": {}
},
"giftcardAmounts": [
{
"websiteId": 0,
"value": 0,
"websiteValue": 0,
"extensionAttributes": {}
}
],
"configurableProductOptions": [
{
"id": 0,
"attributeId": "string",
"label": "string",
"position": 0,
"isUseDefault": true,
"values": [
{
"valueIndex": 0,
"extensionAttributes": {}
}
],
"extensionAttributes": {},
"productId": 0
}
],
"configurableProductLinks": [
0
],
"bundleProductOptions": [
{
"optionId": 0,
"title": "string",
"required": true,
"type": "string",
"position": 0,
"sku": "string",
"productLinks": [
{
"id": "string",
"sku": "string",
"optionId": 0,
"qty": 0,
"position": 0,
"isDefault": true,
"price": 0,
"priceType": 0,
"canChangeQuantity": 0,
"extensionAttributes": {}
}
],
"extensionAttributes": {}
}
]
},
"productLinks": [
{
"sku": "string",
"linkType": "string",
"linkedProductSku": "string",
"linkedProductType": "string",
"position": 0,
"extensionAttributes": {
"qty": 0
}
}
],
"options": [
{
"productSku": "string",
"optionId": 0,
"title": "string",
"type": "string",
"sortOrder": 0,
"isRequire": true,
"price": 0,
"priceType": "string",
"sku": "string",
"fileExtension": "string",
"maxCharacters": 0,
"imageSizeX": 0,
"imageSizeY": 0,
"values": [
{
"title": "string",
"sortOrder": 0,
"price": 0,
"priceType": "string",
"sku": "string",
"optionTypeId": 0
}
],
"extensionAttributes": {}
}
],
"mediaGalleryEntries": [
{
"id": 0,
"mediaType": "string",
"label": "string",
"position": 0,
"disabled": true,
"types": [
"string"
],
"file": "string",
"content": {
"base64EncodedData": "string",
"type": "string",
"name": "string"
},
"extensionAttributes": {
"videoContent": {
"mediaType": "string",
"videoProvider": "string",
"videoUrl": "string",
"videoTitle": "string",
"videoDescription": "string",
"videoMetadata": "string"
}
}
}
],
"tierPrices": [
{
"customerGroupId": 0,
"qty": 0,
"value": 0,
"extensionAttributes": {}
}
],
"customAttributes": [
{
"attributeCode": "string",
"value": "string"
}
]
},
"saveOptions": true
}
Related
Probably there are many question on JSON schema, however, I couldn't find an answer I was looking for.
I have a JSON message where the block inside FlagDetails array can come a max of 300 times. How do I restrict this using the schema which I have created below so that Time and UID can come max of 300 but max occurrences is 1 per array block.
JSON body:
{
"SData": {
"IData": {
"IDatas": {
"Flag": "Yes",
"FlagDetails": [
{
"Time": "2012-07-06 09:30:00",
"UID": 1234567
},
{
"Time": "2012-07-06 09:30:00",
"UID": 1234567
}
]
}
}
}
}
JSON schema:
{
"definitions": {},
"type": "object",
"required": [
"SData"
],
"properties": {
"SData": {
"title": "SData",
"type": "object",
"required": [
"IData"
],
"properties": {
"IData": {
"title": "IData",
"type": "object",
"required": [
"IDatas"
],
"properties": {
"IDatas": {
"title": "IDatas",
"type": "object",
"required": [
"Flag"
],
"properties": {
"Flag": {
"title": "Flag",
"type": "string",
"default": "",
"examples": [
"Yes"
],
"minLength": 2,
"maxLength": 3,
"minOccurs": 0,
"maxOccurs": 1,
"pattern": "^.*$"
},
"FlagDetails": {
"title": "FlagDetails",
"type": "array",
"default": [],
"items": {
"title": "Items",
"type": "object",
"properties": {
"Time": {
"title": "Time",
"type": "string",
"default": "",
"examples": [
"2012-07-06 09:30:00"
],
"minOccurs": 0,
"pattern": "^.*$"
},
"UID": {
"title": "UId",
"type": "integer",
"default": "",
"examples": [
"12345678912"
],
"minLength": 4,
"maxLength": 12,
"minOccurs": 0,
"pattern": "^.*$"
}
}
}
}
}
}
}
}
}
}
}
}
The answer to this is "minItems" & "maxItems". I have used those and it works perfectly.
"FlagDetails": {
"title": "FlagDetails",
"type": "array",
**"minItems": 0,
"maxItems": 300,**
"default": []
This is the example JSON
{
"customerId": 0,
"authorizedCustomerIds": [
0
],
"creativeVersionId": 0,
"description": "string",
"version": "string",
"duration": 0,
"frameRate": 0,
"previewImage": "string",
"previewVideo": "string",
"renderScript": "string",
"renderScriptType": "string",
"elements": [
{
"id": 0,
"type": "IMAGE",
"name": "string1",
"parentId": 0,
"presetId": 0,
"properties": [
{
"name": "string",
"value": {},
"type": "ALPHABETIC",
"producesVideo": true,
"renderScriptId": "string"
}
]
},
{
"id": 1,
"type": "TEXT",
"name": "string2",
"parentId": 0,
"presetId": 0,
"properties": [
{
"name": "string",
"value": {},
"type": "ALPHABETIC",
"producesVideo": false,
"renderScriptId": "string"
}
]
}
],
"globalElements": [
{
"id": 0,
"disabled": true
}
],
"shots": [
{
"name": "string",
"displayOrder": 0,
"startFrame": 0,
"duration": 0,
"thumbnailFrame": 0,
"elements": [
{
"id": 0,
"disabled": true
}
]
}
],
"sizes": [
{
"name": "string",
"displayOrder": 0,
"main": true,
"width": 0,
"height": 0,
"properties": [
{
"templateElementId": 0,
"propertyName": "string",
"linked": true,
"value": {}
}
]
}
]
}
I need to get the element name which type is TEXT and the properties "producesVideo" is false.
I tried this way but it not works
$..elements[?(#.type == 'TEXT' && #.properties[?(#.producesVideo == false)])].name
Then I need to extract the path with rest assured
.extract().path();
using find or findAll conditions
What JSONPath implementation are you using? For that document and JSONPath expression, some implementations, e.g. jayway Java and jsoncons C++, will return the value result
[
"string2"
]
or the path result
[
"$['elements'][1]['name']"
]
Other implementations, e.g. Goessner Javascript, can't digest a filter expression with a subfilter. Christoph Burgmer's JSONPath Comparison covers that case here.
using rest assured find and findAll expressions the jsonpath should be like this:
.extract().path("elements.findAll{it.type == 'TEXT' && it.properties.find{it.producesVideo == false}}.name");
I built my Conversational AI chatbot and followed all the steps to connect it to Alexa but when I try to call my chatbot in alexa simulator,I get the following message:
"There was a problem with the requested skill's response"
this is the code which appears on JSON output 1 and JSON output 2 after the error:
{
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.5e3bb3da-ba51-4422-80cb-c5cace7e3756",
"application": {
"applicationId": "amzn1.ask.skill.bfb81ac5-d463-4201-b70c-a35f8cc6dbed"
},
"user": {
"userId": "amzn1.ask.account.AHIAWE37M4SE4Q7DBFIIRLYZYXFKPU42HAD35P5XLHMZA4RGRXFERFRKPAN2I34A56TCC2XEGVNKYH7SW2KVB2NBUYAAY73GRDDXNEFFFY46W2FJXXCLSMAIUWDEUESU3ZMGIYPPYA2WXFXBBHGJBLHNVRYBLXTBLOCJMGOMK4VXNONXGGICYKBBIE7LMCTSUOVEYRAS3E2ATNQ"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.bfb81ac5-d463-4201-b70c-a35f8cc6dbed"
},
"user": {
"userId": "amzn1.ask.account.AHIAWE37M4SE4Q7DBFIIRLYZYXFKPU42HAD35P5XLHMZA4RGRXFERFRKPAN2I34A56TCC2XEGVNKYH7SW2KVB2NBUYAAY73GRDDXNEFFFY46W2FJXXCLSMAIUWDEUESU3ZMGIYPPYA2WXFXBBHGJBLHNVRYBLXTBLOCJMGOMK4VXNONXGGICYKBBIE7LMCTSUOVEYRAS3E2ATNQ"
},
"device": {
"deviceId": "amzn1.ask.device.AHAUYPX373VS2JXBI2E5VG4GPJPAUT5I5KRINQVJCDM7C7MZFGHWSEQV6CKKSHEZQT7HRAIAHS5BRCKLRHDDRTOE3XYWTDOSIW4MKRXAEGZIWA6XQTXY7TRC26PTPZWWB5T6D77XQNDTPLUTKRBOCJ2KLCCYRBUMXLD2GLKU4K2OQXHJDAM4Q",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLmJmYjgxYWM1LWQ0NjMtNDIwMS1iNzBjLWEzNWY4Y2M2ZGJlZCIsImV4c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SElBV0UzN000U0U0UTdEQkZJSVJMWVpZWEZLUFU0MkhBRDM1UDVYTEhNWkE0UkdSWEZFUkZSS1BBTjJJMzRBNTZUQ0MyWEVHVk5LWUg3U1cyS1ZCMk5CVVlBQVk3M0dSRERYTkVGRkZZNDZXMkZKWFhDTFNNQUlVV0RFVUVTVTNaTUdJWVBQWUEyV1hGWEJCSEdKQkxITlZSWUJMWFRCTE9DSk1HT01LNFZYTk9OWEdHSUNZS0JCSUU3TE1DVFNVT1ZFWVJBUzNFMkFUTlEifX0.UV1qiib5UAV4msb27bxN6zBtPnaYg_1ifwWQhuSXNQpDUzM8dQlo29T5O425Itz6M-xufZT5wtJpk-mT2JZUWjdAe8bquTT9YAmAroAp3_Sa-OJ1iXP8qhiPQeu8g7Xwl2XVpFUAuaeqoSyZxzM2dnKBIND18qrcDfDTS9YRzwcrQdBaGlH-_uW0nXDOntyZ7myqB50fBVtlz5xiayHFE5J3-OTaMK4nuggMKzuL8lbYQrcEPwwbt940LiKy4CRjltHA83N1xtyBtkafcOFQPN3UAzFKPI85jUtIFuYUsuIbl7N_f64yOAgtkIQEvjCA-DWQzkerPyHJo2VrF0q7Tw"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
},
"Viewports": [
{
"type": "APL",
"id": "main",
"shape": "RECTANGLE",
"dpi": 160,
"presentationType": "STANDARD",
"canRotate": false,
"configuration": {
"current": {
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
},
"size": {
"type": "DISCRETE",
"pixelWidth": 1024,
"pixelHeight": 600
}
}
}
}
]
},
"request": {
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.1d812f0b-5bce-42a6-bdd5-4791d5876e8e",
"timestamp": "2020-01-22T09:20:12Z",
"locale": "en-US",
"shouldLinkResultBeReturned": false
}}
JSON Output 2:
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.5e3bb3da-ba51-4422-80cb-c5cace7e3756",
"application": {
"applicationId": "amzn1.ask.skill.bfb81ac5-d463-4201-b70c-a35f8cc6dbed"
},
"user": {
"userId": "amzn1.ask.account.AHIAWE37M4SE4Q7DBFIIRLYZYXFKPU42HAD35P5XLHMZA4RGRXFERFRKPAN2I34A56TCC2XEGVNKYH7SW2KVB2NBUYAAY73GRDDXNEFFFY46W2FJXXCLSMAIUWDEUESU3ZMGIYPPYA2WXFXBBHGJBLHNVRYBLXTBLOCJMGOMK4VXNONXGGICYKBBIE7LMCTSUOVEYRAS3E2ATNQ"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.bfb81ac5-d463-4201-b70c-a35f8cc6dbed"
},
"user": {
"userId": "amzn1.ask.account.AHIAWE37M4SE4Q7DBFIIRLYZYXFKPU42HAD35P5XLHMZA4RGRXFERFRKPAN2I34A56TCC2XEGVNKYH7SW2KVB2NBUYAAY73GRDDXNEFFFY46W2FJXXCLSMAIUWDEUESU3ZMGIYPPYA2WXFXBBHGJBLHNVRYBLXTBLOCJMGOMK4VXNONXGGICYKBBIE7LMCTSUOVEYRAS3E2ATNQ"
},
"device": {
"deviceId": "amzn1.ask.device.AHAUYPX373VS2JXBI2E5VG4GPJPAUT5I5KRINQVJCDM7C7MZFGHWSEQV6CKKSHEZQT7HRAIAHS5BRCKLRHDDRTOE3XYWTDOSIW4MKRXAEGZIWA6XQTXY7TRC26PTPZWWB5T6D77XQNDTPLUTKRBOCJ2KLCCYRBUMXLD2GLKU4K2OQXHJDAM4Q",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwcz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UlhBRUdaSVdBNlhRVFhZN1RSQzI2UFRQWldXQjVUNkQ3N1hRTkRUUExVVEtSQk9DSjJLTENDWVJCVU1YTEQyR0xLVTRLMk9RWEhKREFNNFEiLCJ1c2VySWQiOiJhbXpuMS5hc2suYWNjb3VudC5BSElBV0UzN000U0U0UTdEQkZJSVJMWVpZWEZLUFU0MkhBRDM1UDVYTEhNWkE0UkdSWEZFUkZSS1BBTjJJMzRBNTZUQ0MyWEVHVk5LWUg3U1cyS1ZCMk5CVVlBQVk3M0dSRERYTkVGRkZZNDZXMkZKWFhDTFNNQUlVV0RFVUVTVTNaTUdJWVBQWUEyV1hGWEJCSEdKQkxITlZSWUJMWFRCTE9DSk1HT01LNFZYTk9OWEdHSUNZS0JCSUU3TE1DVFNVT1ZFWVJBUzNFMkFUTlEifX0.UV1qiib5UAV4msb27bxN6zBtPnaYg_1ifwWQhuSXNQpDUzM8dQlo29T5O425Itz6M-xufZT5wtJpk-mT2JZUWjdAe8bquTT9YAmAroAp3_Sa-OJ1iXP8qhiPQeu8g7Xwl2XVpFUAuaeqoSyZxzM2dnKBIND18qrcDfDTS9YRzwcrQdBaGlH-_uW0nXDOntyZ7myqB50fBVtlz5xiayHFE5J3-OTaMK4nuggMKzuL8lbYQrcEPwwbt940LiKy4CRjltHA83N1xtyBtkafcOFQPN3UAzFKPI85jUtIFuYUsuIbl7N_f64yOAgtkIQEvjCA-DWQzkerPyHJo2VrF0q7Tw"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
},
"Viewports": [
{
"type": "APL",
"id": "main",
"shape": "RECTANGLE",
"dpi": 160,
"presentationType": "STANDARD",
"canRotate": false,
"configuration": {
"current": {
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
},
"size": {
"type": "DISCRETE",
"pixelWidth": 1024,
"pixelHeight": 600
}
}
}
}
]
},
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.30c39df8-dc26-4dcf-a193-de432a3a0ab1",
"timestamp": "2020-01-22T09:20:13Z",
"locale": "en-US",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}}{
"body": {
"version": "1.0",
"response": {
"type": "_DEFAULT_RESPONSE"
},
"sessionAttributes": {},
"userAgent": "ask-node/2.7.0 Node/v8.15.0"
}
}
Using Draft-07
What I got was
valid JSON
What error I expected from audit object was
directory: String length must be greater than or equal to 2
Tried two different validators with same results
https://www.jsonschemavalidator.net/
GoLang https://github.com/xeipuuv/gojsonschema
This is my schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ISAM-Wrapper",
"description": "Validate isam wrapper json",
"type": "object",
"properties": {
"directory": {
"description": "path to location of isam file",
"type": "string",
"minLength": 2
},
"isamFile": {
"description": "isam database file",
"type": "string",
"minLength": 4
},
"isamIndex": {
"description": "isam index file",
"type": "string",
"minLength": 4
},
"port": {
"description": "port number for REST listener",
"type": "integer",
"minimum": 60410,
"maximum": 69999
},
"actions": {
"description": "Which operations are supported",
"type": "object",
"items": {
"properties": {
"create": {
"type": "boolean"
},
"read": {
"type": "boolean"
},
"update": {
"type": "boolean"
},
"delete": {
"type": "boolean"
}
}
},
"required": [
"create",
"read",
"update",
"delete"
]
},
"fields": {
"description": "each object describes one field of the isam file",
"type": "array",
"minItems": 1,
"items": {
"title": "field",
"description": "field schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"ordinal": {
"type": "integer",
"minimum": 0
},
"offset": {
"type": "integer",
"minimum": 0
},
"length": {
"type": "integer",
"minimum": 1
},
"dataType": {
"enum": [
"uchar",
"ulong",
"long",
"uint",
"int",
"ushort",
"short"
]
}
},
"required": [
"name",
"ordinal",
"offset",
"length",
"dataType"
]
}
},
"audit": {
"description": "input needed to enable and configure isam auditing",
"type": "object",
"items": {
"properties": {
"enable": {
"enum": [
true,
false
]
},
"directory": {
"type": "string",
"minLength": 2
},
"fileName": {
"type": "string",
"minLength": 4
},
"workDirectory": {
"type": "string",
"minLength": 2
},
"archiveDirectory": {
"type": "string",
"minLength": 2
},
"interval": {
"type": "integer",
"minimum": 1
},
"byteThreshold": {
"type": "integer",
"minimum": 1048576,
"maximum": 1073741824
}
}
},
"required": [
"enable"
],
"if": {
"not": {
"properties": {
"enable": {
"enum": [
false
]
}
}
}
},
"then": {
"required": [
"directory",
"fileName",
"workDirectory",
"archiveDirectory",
"interval",
"byteThreshold"
]
}
}
},
"required": [
"directory",
"isamFile",
"isamIndex",
"port",
"actions",
"fields",
"audit"
]
}
This is my JSON
{
"directory": "./",
"isamFile": "isam.dat",
"isamIndex": "isam.idx",
"port": 60410,
"actions": {
"create": true,
"read": true,
"update": true,
"delete": true
},
"fields": [
{
"name": "F1",
"ordinal": 0,
"offset": 0,
"length": 4,
"dataType": "ulong"
},
{
"name": "F2",
"ordinal": 1,
"offset": 4,
"length": 4,
"dataType": "ulong"
}
],
"audit": {
"enable": true,
"directory": "",
"fileName": "file",
"workDirectory": "./work",
"archiveDirectory": "./archive",
"interval": 5,
"byteThreshold": 1500000
}
}
This issue you have is that your schema is invalid. For both actions and audit you specify these as objects but you don't provide any properties. What you do do, however, is specify an items key (which does nothing here - that's a key on an array) which contains the properties.
Once you correct this error, the schema behaves as you intend, see https://repl.it/repls/BlankWellmadeFrontpage
I have an elastic search implementation with parent and child relationship.
The parent (products) type has two child types(productfeatures, supplierpna).
I have the search feature on my application which needs to return the parent document based on the productcode field in the "products" type.
What I need is to get all child documents attached to the parent as a sub nested list with a single filtered query.
e.g. productcode = "123456" will return 10 products but some products has the child object and some don't, but I want to get the parent document regardless the child document existence.
I tried has_child option but it do not return the parent document when there is no child objects
Here is my mapping, any help in this regard will be very helpful.
{ "itdealer": {
"aliases": {},
"mappings": {
"products": {
"properties": {
"categoryname": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem",
"fields": {
"categoryname_ags": {
"type": "string",
"index": "not_analyzed"
}
}
},
"highPic": {
"type": "string",
"index": "no",
"include_in_all": false
},
"id": {
"type": "string"
},
"longDescription": {
"type": "string"
},
"lowPic": {
"type": "string",
"index": "no",
"include_in_all": false
},
"manufacturername": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem",
"fields": {
"manufacturername_ags": {
"type": "string",
"index": "not_analyzed"
}
}
},
"modelName": {
"type": "string",
"index": "no",
"include_in_all": false
},
"productManualPdfUrl": {
"type": "string",
"index": "no",
"include_in_all": false
},
"productPdfUrl": {
"type": "string",
"index": "no",
"include_in_all": false
},
"productSpecifications": {
"type": "nested",
"include_in_parent": true,
"include_in_root": true,
"include_in_all": true,
"properties": {
"featureGroupName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower",
"include_in_all": true
},
"featureGroupName.featureName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower",
"include_in_all": true
},
"featureGroupName.featureValue": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower",
"include_in_all": true
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "special",
"include_in_all": true
}
}
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"store": true,
"index_analyzer": "special"
},
"searchTerms": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem"
},
"shortDescription": {
"type": "string",
"store": true
},
"subCategoryname": {
"type": "string",
"index_analyzer": "keylower",
"search_analyzer": "stem",
"fields": {
"subCategoryname_ags": {
"type": "string",
"index": "not_analyzed"
}
}
},
"thumbPic": {
"type": "string",
"index": "no",
"include_in_all": false
},
"title": {
"type": "string",
"analyzer": "keylower",
"fields": {
"title_ac": {
"type": "string",
"index_analyzer": "pr_autocomplete",
"search_analyzer": "keylower"
},
"title_stem": {
"type": "string",
"index_analyzer": "stem",
"search_analyzer": "keylower"
}
}
},
"warrantyInfo": {
"type": "string",
"index": "no",
"include_in_all": false
}
}
},
"productfeatures": {
"_parent": {
"type": "products"
},
"_routing": {
"required": true
},
"properties": {
"featureGroupName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"featureGroupName.featureName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"featureGroupName.featureValue": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"features": {
"properties": {
"featureName": {
"type": "string"
},
"featureValue": {
"type": "string"
}
}
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "special"
}
}
},
"supplierpna": {
"_parent": {
"type": "products"
},
"_routing": {
"required": true
},
"properties": {
"freeStock": {
"type": "string",
"index": "no",
"include_in_all": false
},
"manufacturer": {
"type": "string",
"index": "no",
"include_in_all": false
},
"partNumber": {
"type": "string",
"index": "not_analyzed",
"store": true,
"index_analyzer": "special"
},
"productcode": {
"type": "string",
"index": "not_analyzed",
"store": true
},
"rRP": {
"type": "double",
"store": true
},
"supplier": {
"type": "string",
"index": "not_analyzed",
"include_in_all": false
},
"supplierId": {
"type": "double",
"index": "no"
},
"supplierLogo": {
"type": "string",
"index": "no",
"include_in_all": false
},
"supplierName": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "keylower"
},
"supplierProductDescription": {
"type": "string",
"index": "no",
"include_in_all": false
},
"supplierURL": {
"type": "string",
"index": "no",
"include_in_all": false
},
"updatedDate": {
"type": "date",
"index": "no",
"format": "dateOptionalTime",
"include_in_all": false
}
}
}
},
"settings": {
"index": {
"mapping": {
"allow_type_wrapper": "true"
},
"search": {
"slowlog": {
"threshold": {
"fetch": {
"warn": "1s"
}
}
}
},
"number_of_shards": "5",
"merge": {
"policy": {
"merge_factor": "10"
}
},
"creation_date": "1432827491555",
"analysis": {
"filter": {
"special": {
"split_on_numerics": "false",
"generate_word_parts": "false",
"preserve_original": "true",
"generate_number_parts": "false",
"split_on_case_change": "false",
"type_table": [
"# => ALPHA",
"- => ALPHA",
"$ => ALPHA",
"% => ALPHA"
],
"type": "word_delimiter"
},
"stemming": {
"type": "stemmer",
"language": "light_english"
},
"autocomplete": {
"min_gram": "1",
"type": "edge_ngram",
"stopwords": "_english_",
"max_gram": "20"
}
},
"analyzer": {
"special": {
"filter": [
"lowercase",
"special"
],
"type": "custom",
"tokenizer": "keyword"
},
"keylower": {
"filter": "lowercase",
"tokenizer": "standard"
},
"pr_autocomplete": {
"type": "custom",
"filter": [
"lowercase",
"autocomplete"
],
"tokenizer": "standard"
},
"stem": {
"filter": [
"lowercase",
"stemming"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_replicas": "1",
"version": {
"created": "1050299"
},
"uuid": "D1spSYWURBWIfXYRcsY6cg"
}
},
"warmers": {}}}
My current normal search query data
{
"query": {
"filtered": {
"query": {
"multi_match": {
"fields": [
"searchTerms",
"manufacturername^7",
"subCategoryname^4",
"title_ac^10",
"categoryname",
"shortDescription",
"productcode"
],
"query": "hp desktop",
"type": "cross_fields",
"operator": "or",
"tie_breaker": 0.3
}
}
}
},
"size": "10",
"from": "0",
"aggs": {
"manufacture": {
"terms": {
"field": "manufacturername_ags",
"size": 0,
"order": {
"_count": "desc"
}
}
},
"category": {
"terms": {
"field": "categoryname_ags",
"size": 0,
"order": {
"_count": "desc"
}
}
},
"subcategory": {
"terms": {
"field": "subCategoryname_ags",
"size": 0,
"order": {
"_count": "desc"
}
}
}
}
}
Right now this query only returns the parent document I want this query to be modified so that I will include the child objects both (productfeatures and supplierpna) in each parent document.