How to store shop products in ElasticsearchElasticsearch query to return all recordsMake elasticsearch only return certain fields?Solr vs. ElasticSearchHow to build a list of filterable options from a query result?Removing Data From ElasticSearchStacking filters in ElasticSearchElastic and aggregations performanceElasticSearch - Match all nested variations in a documentElasticsearch: build binary mask based on filterSearching and filtering on elasticsearch vs searching on elasticsearch and filtering on postgres
Is HostGator storing my password in plaintext?
How do we know the LHC results are robust?
How can I kill an app using Terminal?
System.debug(JSON.Serialize(o)) Not longer shows full string
How can we prove that any integral in the set of non-elementary integrals cannot be expressed in the form of elementary functions?
Proof of work - lottery approach
How does it work when somebody invests in my business?
Would a high gravity rocky planet be guaranteed to have an atmosphere?
How do I find the solutions of the following equation?
Is exact Kanji stroke length important?
A particular customize with green line and letters for subfloat
How long to clear the 'suck zone' of a turbofan after start is initiated?
Failed to fetch jessie backports repository
You cannot touch me, but I can touch you, who am I?
How to safely derail a train during transit?
Why, precisely, is argon used in neutrino experiments?
Do the temporary hit points from the Battlerager barbarian's Reckless Abandon stack if I make multiple attacks on my turn?
How to Reset Passwords on Multiple Websites Easily?
Method to test if a number is a perfect power?
How did Doctor Strange see the winning outcome in Avengers: Infinity War?
Why not increase contact surface when reentering the atmosphere?
Pre-amplifier input protection
Avoiding estate tax by giving multiple gifts
CREATE opcode: what does it really do?
How to store shop products in Elasticsearch
Elasticsearch query to return all recordsMake elasticsearch only return certain fields?Solr vs. ElasticSearchHow to build a list of filterable options from a query result?Removing Data From ElasticSearchStacking filters in ElasticSearchElastic and aggregations performanceElasticSearch - Match all nested variations in a documentElasticsearch: build binary mask based on filterSearching and filtering on elasticsearch vs searching on elasticsearch and filtering on postgres
We have an online shop that stores product details in three tables:
- Products (Name, Description, Brand) - total 10.000 entries
- Product-Variants (Size, Price, Availability) - total 80.000 entries
- Product-Attributes (Colors) - total 60.000 entries
That gives a total combination of about 400.000 items.
Example:
- Product is "Nike Air Max"
- Variants are "Size 36, 70 USD", "Size 37, 72 USD", "Size 38, 74 USD"
- Attributes are "Color red" and "Color black"
- Total 6 combinations ("Nike Air Max + 36 + red", "Nike Air Max + 36 + black" ...)
I'm looking for a way to store the elements in elastic to get best filter performance, for queries like "Give me all products in size 34 - 37 in colors red or orange, that cost below 90 USD"
How should I reflect this setup in Elasticsearch, i.e. which indices should I create to get optimal search and filter performance (index-performance is not so important)
Note: I've seen keywords like "denormalization", "nested documents" and "child documents" but not sure on which approach I should read more and implement.
elasticsearch
add a comment |
We have an online shop that stores product details in three tables:
- Products (Name, Description, Brand) - total 10.000 entries
- Product-Variants (Size, Price, Availability) - total 80.000 entries
- Product-Attributes (Colors) - total 60.000 entries
That gives a total combination of about 400.000 items.
Example:
- Product is "Nike Air Max"
- Variants are "Size 36, 70 USD", "Size 37, 72 USD", "Size 38, 74 USD"
- Attributes are "Color red" and "Color black"
- Total 6 combinations ("Nike Air Max + 36 + red", "Nike Air Max + 36 + black" ...)
I'm looking for a way to store the elements in elastic to get best filter performance, for queries like "Give me all products in size 34 - 37 in colors red or orange, that cost below 90 USD"
How should I reflect this setup in Elasticsearch, i.e. which indices should I create to get optimal search and filter performance (index-performance is not so important)
Note: I've seen keywords like "denormalization", "nested documents" and "child documents" but not sure on which approach I should read more and implement.
elasticsearch
add a comment |
We have an online shop that stores product details in three tables:
- Products (Name, Description, Brand) - total 10.000 entries
- Product-Variants (Size, Price, Availability) - total 80.000 entries
- Product-Attributes (Colors) - total 60.000 entries
That gives a total combination of about 400.000 items.
Example:
- Product is "Nike Air Max"
- Variants are "Size 36, 70 USD", "Size 37, 72 USD", "Size 38, 74 USD"
- Attributes are "Color red" and "Color black"
- Total 6 combinations ("Nike Air Max + 36 + red", "Nike Air Max + 36 + black" ...)
I'm looking for a way to store the elements in elastic to get best filter performance, for queries like "Give me all products in size 34 - 37 in colors red or orange, that cost below 90 USD"
How should I reflect this setup in Elasticsearch, i.e. which indices should I create to get optimal search and filter performance (index-performance is not so important)
Note: I've seen keywords like "denormalization", "nested documents" and "child documents" but not sure on which approach I should read more and implement.
elasticsearch
We have an online shop that stores product details in three tables:
- Products (Name, Description, Brand) - total 10.000 entries
- Product-Variants (Size, Price, Availability) - total 80.000 entries
- Product-Attributes (Colors) - total 60.000 entries
That gives a total combination of about 400.000 items.
Example:
- Product is "Nike Air Max"
- Variants are "Size 36, 70 USD", "Size 37, 72 USD", "Size 38, 74 USD"
- Attributes are "Color red" and "Color black"
- Total 6 combinations ("Nike Air Max + 36 + red", "Nike Air Max + 36 + black" ...)
I'm looking for a way to store the elements in elastic to get best filter performance, for queries like "Give me all products in size 34 - 37 in colors red or orange, that cost below 90 USD"
How should I reflect this setup in Elasticsearch, i.e. which indices should I create to get optimal search and filter performance (index-performance is not so important)
Note: I've seen keywords like "denormalization", "nested documents" and "child documents" but not sure on which approach I should read more and implement.
elasticsearch
elasticsearch
asked Mar 21 at 15:29
PhilippPhilipp
3,47923040
3,47923040
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You have 2 ways to do this
- create one document by kind of shoes (=Product) each of them will store all information about this product. This will minimize the number of documents in your cluster.
Something like
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
nested:
variant:
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
- Create one document by shoes, you will have a lots of documents.
.
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
If you have to work with query like you said, the second solution would be better (you wont have to filter nested fields, stats or aggregation will be easy and 400k items will be easy for elasticsearch), if you are looking to make a search engine for a website I think this is better. If you need to make stats, or a backoffice tools by "Product", the first model could be better.
add a comment |
(drumrolls...) It depends!
To be a bit more constructive, it depends on how you want to fetch those products. If you want to search for a red, size 40 specifically, you'll probably need nested documents.
Here's a short example:
"name":"Air max", variants: [color:"red", size:"36", color:"black", size:"40"]
Now if we consider that variants are nested documents, and you're still looking for a size 40 red, then ES will correclty return 0 results.
Without nested documents, the internal index will look something like this:
"name":"Air max", variants.color:"red" "black", variants.size:"36" "40"
And with that kind of data structure, ES will return you the document for a size 40 red.
Now if you really want to use nested documents, be aware that it comes with some drawbacks in terms of performance, compatibility with different software related to ES (looking at you, Kibana), ...
– haltabush
Mar 21 at 15:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283961%2fhow-to-store-shop-products-in-elasticsearch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have 2 ways to do this
- create one document by kind of shoes (=Product) each of them will store all information about this product. This will minimize the number of documents in your cluster.
Something like
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
nested:
variant:
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
- Create one document by shoes, you will have a lots of documents.
.
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
If you have to work with query like you said, the second solution would be better (you wont have to filter nested fields, stats or aggregation will be easy and 400k items will be easy for elasticsearch), if you are looking to make a search engine for a website I think this is better. If you need to make stats, or a backoffice tools by "Product", the first model could be better.
add a comment |
You have 2 ways to do this
- create one document by kind of shoes (=Product) each of them will store all information about this product. This will minimize the number of documents in your cluster.
Something like
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
nested:
variant:
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
- Create one document by shoes, you will have a lots of documents.
.
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
If you have to work with query like you said, the second solution would be better (you wont have to filter nested fields, stats or aggregation will be easy and 400k items will be easy for elasticsearch), if you are looking to make a search engine for a website I think this is better. If you need to make stats, or a backoffice tools by "Product", the first model could be better.
add a comment |
You have 2 ways to do this
- create one document by kind of shoes (=Product) each of them will store all information about this product. This will minimize the number of documents in your cluster.
Something like
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
nested:
variant:
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
- Create one document by shoes, you will have a lots of documents.
.
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
If you have to work with query like you said, the second solution would be better (you wont have to filter nested fields, stats or aggregation will be easy and 400k items will be easy for elasticsearch), if you are looking to make a search engine for a website I think this is better. If you need to make stats, or a backoffice tools by "Product", the first model could be better.
You have 2 ways to do this
- create one document by kind of shoes (=Product) each of them will store all information about this product. This will minimize the number of documents in your cluster.
Something like
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
nested:
variant:
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
- Create one document by shoes, you will have a lots of documents.
.
shoes
"name": "type": "keyword" ,
"brand": "type": "keyword" ,
"Description":
"type": "string",
"index": "not_analyzed"
size: "type": "integer" ,
price: "type": "float" ,
availability: "type": "integer" ,
colors: "type": "keyword"
If you have to work with query like you said, the second solution would be better (you wont have to filter nested fields, stats or aggregation will be easy and 400k items will be easy for elasticsearch), if you are looking to make a search engine for a website I think this is better. If you need to make stats, or a backoffice tools by "Product", the first model could be better.
edited Mar 21 at 20:01
marc_s
583k13011241270
583k13011241270
answered Mar 21 at 15:58
LeBigCatLeBigCat
621212
621212
add a comment |
add a comment |
(drumrolls...) It depends!
To be a bit more constructive, it depends on how you want to fetch those products. If you want to search for a red, size 40 specifically, you'll probably need nested documents.
Here's a short example:
"name":"Air max", variants: [color:"red", size:"36", color:"black", size:"40"]
Now if we consider that variants are nested documents, and you're still looking for a size 40 red, then ES will correclty return 0 results.
Without nested documents, the internal index will look something like this:
"name":"Air max", variants.color:"red" "black", variants.size:"36" "40"
And with that kind of data structure, ES will return you the document for a size 40 red.
Now if you really want to use nested documents, be aware that it comes with some drawbacks in terms of performance, compatibility with different software related to ES (looking at you, Kibana), ...
– haltabush
Mar 21 at 15:46
add a comment |
(drumrolls...) It depends!
To be a bit more constructive, it depends on how you want to fetch those products. If you want to search for a red, size 40 specifically, you'll probably need nested documents.
Here's a short example:
"name":"Air max", variants: [color:"red", size:"36", color:"black", size:"40"]
Now if we consider that variants are nested documents, and you're still looking for a size 40 red, then ES will correclty return 0 results.
Without nested documents, the internal index will look something like this:
"name":"Air max", variants.color:"red" "black", variants.size:"36" "40"
And with that kind of data structure, ES will return you the document for a size 40 red.
Now if you really want to use nested documents, be aware that it comes with some drawbacks in terms of performance, compatibility with different software related to ES (looking at you, Kibana), ...
– haltabush
Mar 21 at 15:46
add a comment |
(drumrolls...) It depends!
To be a bit more constructive, it depends on how you want to fetch those products. If you want to search for a red, size 40 specifically, you'll probably need nested documents.
Here's a short example:
"name":"Air max", variants: [color:"red", size:"36", color:"black", size:"40"]
Now if we consider that variants are nested documents, and you're still looking for a size 40 red, then ES will correclty return 0 results.
Without nested documents, the internal index will look something like this:
"name":"Air max", variants.color:"red" "black", variants.size:"36" "40"
And with that kind of data structure, ES will return you the document for a size 40 red.
(drumrolls...) It depends!
To be a bit more constructive, it depends on how you want to fetch those products. If you want to search for a red, size 40 specifically, you'll probably need nested documents.
Here's a short example:
"name":"Air max", variants: [color:"red", size:"36", color:"black", size:"40"]
Now if we consider that variants are nested documents, and you're still looking for a size 40 red, then ES will correclty return 0 results.
Without nested documents, the internal index will look something like this:
"name":"Air max", variants.color:"red" "black", variants.size:"36" "40"
And with that kind of data structure, ES will return you the document for a size 40 red.
answered Mar 21 at 15:45
haltabushhaltabush
3,99821837
3,99821837
Now if you really want to use nested documents, be aware that it comes with some drawbacks in terms of performance, compatibility with different software related to ES (looking at you, Kibana), ...
– haltabush
Mar 21 at 15:46
add a comment |
Now if you really want to use nested documents, be aware that it comes with some drawbacks in terms of performance, compatibility with different software related to ES (looking at you, Kibana), ...
– haltabush
Mar 21 at 15:46
Now if you really want to use nested documents, be aware that it comes with some drawbacks in terms of performance, compatibility with different software related to ES (looking at you, Kibana), ...
– haltabush
Mar 21 at 15:46
Now if you really want to use nested documents, be aware that it comes with some drawbacks in terms of performance, compatibility with different software related to ES (looking at you, Kibana), ...
– haltabush
Mar 21 at 15:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283961%2fhow-to-store-shop-products-in-elasticsearch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown