简体   繁体   中英

apache solr sorting by price and sale_price

I have the case to show product data with ascending sorting. Let's say i have this data :

{
    "product_name":"Boyfriend 74 series",
    "product_price":489900},
  {
    "product_name":"Skinny 70 Series",
    "product_price":499900},
  {
    "product_name":"Faran Pant",
    "product_sale_price":490000,
    "product_price":549000},
  {
    "product_name":"Dakota Ripped Jeans",
    "product_sale_price":98000,
    "product_price":559000
  }

Could SOLR sorting the data if the data has product_sale_price and product_sale_price less then product_price, so product_sale_price position should be before product_price?

This is what i want :

      {
        "product_name":"Dakota Ripped Jeans",
        "product_sale_price":98000,
        "product_price":559000
      }
      {  
        "product_name":"Boyfriend 74 series",
        "product_price":489900},          
      {
        "product_name":"Faran Pant",
        "product_sale_price":490000,
        "product_price":549000
      },
      {
        "product_name":"Skinny 70 Series",
        "product_price":499900
      },

You can use the sub function

&sort=sub(product_price,product_sale_price)desc

if you want try more on it ...check on the other available functions

https://wiki.apache.org/solr/FunctionQuery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM