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













0















We have an online shop that stores product details in three tables:



  1. Products (Name, Description, Brand) - total 10.000 entries

  2. Product-Variants (Size, Price, Availability) - total 80.000 entries

  3. 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.










share|improve this question


























    0















    We have an online shop that stores product details in three tables:



    1. Products (Name, Description, Brand) - total 10.000 entries

    2. Product-Variants (Size, Price, Availability) - total 80.000 entries

    3. 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.










    share|improve this question
























      0












      0








      0








      We have an online shop that stores product details in three tables:



      1. Products (Name, Description, Brand) - total 10.000 entries

      2. Product-Variants (Size, Price, Availability) - total 80.000 entries

      3. 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.










      share|improve this question














      We have an online shop that stores product details in three tables:



      1. Products (Name, Description, Brand) - total 10.000 entries

      2. Product-Variants (Size, Price, Availability) - total 80.000 entries

      3. 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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 21 at 15:29









      PhilippPhilipp

      3,47923040




      3,47923040






















          2 Answers
          2






          active

          oldest

          votes


















          2














          You have 2 ways to do this



          1. 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"


          1. 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.






          share|improve this answer
































            0














            (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.






            share|improve this answer























            • 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










            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
            );



            );













            draft saved

            draft discarded


















            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









            2














            You have 2 ways to do this



            1. 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"


            1. 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.






            share|improve this answer





























              2














              You have 2 ways to do this



              1. 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"


              1. 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.






              share|improve this answer



























                2












                2








                2







                You have 2 ways to do this



                1. 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"


                1. 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.






                share|improve this answer















                You have 2 ways to do this



                1. 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"


                1. 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.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 21 at 20:01









                marc_s

                583k13011241270




                583k13011241270










                answered Mar 21 at 15:58









                LeBigCatLeBigCat

                621212




                621212























                    0














                    (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.






                    share|improve this answer























                    • 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















                    0














                    (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.






                    share|improve this answer























                    • 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













                    0












                    0








                    0







                    (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.






                    share|improve this answer













                    (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.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    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

















                    • 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

















                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript