How to show results of one-to-many relationship in search results?
-
06-12-2019 - |
Question
We have a one-to-many relationship between a document library (with 150,000 documents) and a custom list storing additional metadata. We're looking to show the additional metadata from all of the related custom list items on the search results of the FAST Search Center. For example:
Result #1
Title
... search excerpt ...
Authors: bla Date: bla Size: bla
Metadata from related custom list item #1
Metadata from related custom list item #2
Metadata from related custom list item #3
Result #2
Title
... search excerpt ...
Authors: bla Date: bla Size: bla
Metadata from related custom list item #1
etc.
The options we've come across are, roughly:
- Add a custom program to the FAST processing pipeline to "flatten" the two lists into one wider, denormalized list
- Create a custom CoreResultsWebPart that runs an additional query for each search result to pull up the additional metadata for the XSLT to display
- Add an event receiver when an item is added to the custom list to merge the data from the two lists and output to a third, denormalized, list which would be crawled for the search index
Is there a simpler solution that we've missed that would accomplish this out of the box? If not, how would you suggest we handle this?
We're using SharePoint Server 2010 Enterprise with FAST Search 2010 for SharePoint.
La solution
Keeping the structure as is I would go with a custom webpart (override the CoreResults web part) and do this as two queries, instead of a custom pipeline module.
First execute your main query, this will give you the id's for all your metadata. Then execute a second query where you retrieve all the list items and their columns in an OR query. No need to execute this query once per item.
Afterwards it's a matter of merging the xml, before rendering it with xslt.
Code wise it would be similar to what I wrote on my blog about blended search.
Autres conseils
I would likely do this through a custom web part that can handle the display. What I'm not sure is if you can grab all of the results up front or if you would have to issue a subsequent request for each of the parent items.