Can i query 2 distinct collections in Solr query?

468 Views Asked by At

I have a requirement where i need to display data of two different solr collection on a page. But the two collections don't have any common field or relation.

e.g.

`Collection 1 fields -> field1(unique key), feild 2, field 3`

Collection 2 fields -> field4(unique key), feild 5

Results should be combination of collection 1 data based on field1 and collection 2 data based on field4.

1

There are 1 best solutions below

4
Abhijit Bashetti On

innerJoin Wraps two streams, Left and Right. For every tuple in Left which exists in Right a tuple containing the fields of both tuples will be emitted. This supports one-to-one, one-to-many, many-to-one, and many-to-many inner join scenarios. The tuples are emitted in the order in which they appear in the Left stream. Both streams must be sorted by the fields being used to determine equality (the 'on' parameter). If both tuples contain a field of the same name then the value from the Right stream will be used in the emitted tuple. You can wrap the incoming streams with a select(…​) expression to be specific about which field values are included in the emitted tuple

You can make use of Solr Streaming expression.

innerJoin(
  search(Collection1, q="*:*", qt="/export", fl="field1, fields2", sort="commonField asc"),
  search(Collection2, q="*:*", qt="/export", fl="field3, fields4", sort="commonField  asc"),
  on="commonField "
)

Please refer the solr link for more option on the same Solr Streaming