Solr: index product and price for sellers and perfoming query and sorting

In my current project,  the modle seller has multiply products with price,  I want to index products and query them then sorting them by price , seller's credit ,the distance between the seller and the user while highlighting the matched products.

 

Due to solr flatten one-to-many relationship, so I should use multiVlaude field to store products and their prices for a seller. 

The schema likes

 
   
   
   
   
   

 

the data indexed likes


    1
    宜宾燃面
    
      39.916927,116.363737
    
    90
    北京西城区
    2015-06-18T15:34:34Z
    
      炒面
      牛肉面
    
    
      23
      18
    
    1510459679273123840
    seller
  

 

The option can't sort product by price.

 

How to do it?

---------------------------------------------------

How about to create two cores to meet  my demands?

sellers likes


    1
    宜宾燃面
    
      39.916927,116.363737
    
    90
    北京西城区
    2015-06-18T15:34:34Z
    1510545445415288832
    seller
  

 

products likes

 
    1
    炒面
    1
    21
    1510545648643997696
  

 

query likes

 "params": {
      "d": "50",
      "indent": "true",
      "spatial": "true",
      "sfield": "location",
      "hl.simple.pre": "",
      "wt": "json",
      "hl": "true",
      "fl": "*,score,dist:geodist()",
      "q": "*:* AND _val_:\"product(scale(credit,1,10),recip(geodist(),3,1,0.1))\"\n",
      "pt": "30.548526,104.062889",
      "_": "1440573751492",
      "hl.simple.post": "",
      "fq": [
        "{!join fromIndex=products toIndex=sellers from=seller_id to=id} name:我要一份牛肉面",
        "{!geofilt}"
      ]

 

but this option can not sort docs by  product's price and highlighting not work.  Meanwhile the product's fileds will not returned.

 

--------------------------------------

How about using nested document model?

but. I found this

All children of a parent document must be indexed together with the parent document. One cannot update any document (parent or child) individually. The entire block needs to be re-indexed of any changes need to be made.

 

Due to seller  updating his products frequently, this option cann't meet our situation.

 

 

--------------------------------------

 

 

 

 

References

http://stackoverflow.com/questions/7845337/sorting-with-multivalued-field-in-solr

http://yonik.com/solr-nested-objects/

 

 

 

你可能感兴趣的:(Solr,json)