Search code examples
solrsap-commerce-cloud

What's the difference between rangeSets and rangeSet in SolrIndexedProperty type?


While creating a new search facet in Hybris 5.7 I've found that in SolrIndexedProperty type there is an attribute called rangeSet and there is also a many-to-many relation called SolrIndexedProperty2SolrValueRangeSetRelation between SolrIndexedProperty and SolrValueRangeSet.

What's the difference between these fields? None of them is deprecated or something. Which one should I use in order to create my own facet with particular value ranges?


Solution

  • I hope you have already find the answer for your question. Still adding my understanding just in case...

    A SolrValueRangeSet is a collection of related SolrValueRange. There are two different fields in hybris to support rangeSet and rangeSets.

    One can add a SolrValueRangeSet or a Collection of SolrValueRangeSet to a SolrIndexedProperty to support one-2-many or one-2-many-2many property range values. You can consider the later as the enhancement over the prior.

    If you want to allow multi facet ranges for different values you can use rangeSets as shown in below example

    INSERT_UPDATE SolrValueRangeSet;name[unique=true]; qualifier;    type; solrValueRanges(&rangeValueRefID)
                                   ;priceRange-USD   ; PriceRangeUSD;  double; usd-range1, usd-range2
                                   ;priceRange-EUR   ; PriceRangeEUR;  double; eur-range1, eur-range2
    

    SolrValueRange : Define related price range values like below

    INSERT_UPDATE SolrValueRange; &rangeValueRefID;s olrValueRangeSet(name)[unique=true]; name[unique=true]; from; to
     ;usd-range1;priceRange-USD;    Rating 1;  0; 50
     ;usd-range2;priceRange-USD;    Rating 2; 50; 100
     ;eur-range1;priceRange-EUR;    Rating 1;  0; 120
     ;eur-range2;priceRange-EUR;    Rating 2; 120; 300
    
    INSERT_UPDATE SolrIndexedProperty; name[unique = true];rangeSets(name)
                                     ; price range; priceRange-USD , priceRange-EUR