Last active
January 23, 2023 22:13
-
-
Save szabizs/efa7e80a5ebf5553792848e1741d8163 to your computer and use it in GitHub Desktop.
Create an Elasticsearch index with mapping for an ecommerce project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --location --request PUT 'localhost:9200/ecom' \ | |
--header 'Content-Type: application/json' \ | |
--data-raw '{ | |
"mappings": { | |
"dynamic": true, | |
"properties": { | |
"title": { | |
"type": "text", | |
"copy_to": "all_filters" | |
}, | |
"description": { | |
"type": "text", | |
"copy_to": "all_filters" | |
}, | |
"sku": { | |
"type": "keyword", | |
"copy_to": "all_filters" | |
}, | |
"price": { | |
"type": "float" | |
}, | |
"category": { | |
"type": "keyword", | |
"copy_to": "all_filters" | |
}, | |
"is_active": { | |
"type": "boolean", | |
"null_value": false | |
}, | |
"is_featured": { | |
"type": "boolean", | |
"null_value": false | |
}, | |
"available_quantity": { | |
"type": "integer" | |
}, | |
"labels": { | |
"type": "nested", | |
"properties": { | |
"label": { | |
"type": "keyword", | |
"copy_to": "all_filters" | |
}, | |
"color": { | |
"type": "keyword" | |
} | |
} | |
}, | |
"images": { | |
"type": "nested", | |
"properties": { | |
"is_main": { | |
"type": "boolean", | |
"null_value": false | |
}, | |
"thumbnail": { | |
"type": "text" | |
}, | |
"medium": { | |
"type": "text" | |
}, | |
"original": { | |
"type": "text" | |
} | |
} | |
}, | |
"filters": { | |
"type": "nested", | |
"properties": { | |
"name": { | |
"type": "keyword", | |
"copy_to": "all_filters" | |
}, | |
"value": { | |
"type": "keyword", | |
"copy_to": "all_filters" | |
}, | |
"label": { | |
"type": "keyword", | |
"copy_to": "all_filters" | |
}, | |
"pretty_name": { | |
"type": "keyword", | |
"copy_to": "all_filters" | |
} | |
} | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment