简体   繁体   中英

Solr join across multiple collections and fetch data from both collections

I have 2 solr collections:

Ads {id, title, body, description, etc etc)

AdPlacement (ad_id, placement_id, price)

Each Ad can have 500-1000 placements, with different prices.

The search usecase is where I have a placement and some search keyword and I want to find the Ads that map the keyword provided in the title/body/description fields and it should be sorted by the price in the AdPlacement collection for the given placement. We would like to get the Ad details and the price in the output returned.

Is there any way to achieve this in solr using join across multiple collections? What I have read so far says you can only get data from one collection and use the other one just for filtering.

Solr is a Document database and supports nested documents so ideally you would want to model such that your add placement records are a part of the Ad document. This would be the better way to handle your scenario. Please go through this blog Solr Nested Objects and the relevant Solr documentation

In case modifying the document structure is not an option then consider this documentation which mentions about allowing some level of join between collections .

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