USM
USM

Reputation: 600

How to do Join in Solr Collections?

I have two solr collections

  1. Collection-A
  2. Collection-B

I need to join these two collections and get one final result with both collections data.

Collection-A:

[
   {
      "uuId": "000000",
      "oName": "IN",
      "paId": "IN01",
      "pName": "ABCD"
   },
   {
      "uuId": "111111",
      "oName": "IN",
      "paId": "IN02",
      "pName": "DEF"
   }
]

Collection-B:

[
   {
      "uuId": "333333",
      "firstName": "John",
      "lastName": "Doe",
      "pId": "IN01",
      "pName": "ABCD"
   },
   {
      "uuId": "444444",
      "firstName": "Saman",
      "lastName": "Lee",
      "pId": "IN02",
      "pName": "DEF"
   }
]

Expected results:

[
   {
      "uuId": "000000",
      "oName": "IN",
      "paId": "IN01",
      "pName": "ABCD",
      "firstName": "John",
      "lastName": "Doe"
   },
   {
      "uuId": "111111",
      "oName": "IN",
      "paId": "IN02",
      "pName": "DEF",
      "firstName": "Saman",
      "lastName": "Lee"
   }
]

Solr UI:

On Collection-A: I have added fq -> {!join from=pId fromIndex=Collection-B to=paId}

I am able to get the results for this, But not getting the Collection-B's firstName,lastName. (Expected results)

Upvotes: 1

Views: 341

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

You can use the joins only to filter the data from solr. You cannot use the solr join to fetch the data from another collection.

Please refer the below link for the same. Solr Join across collection

Upvotes: 1

Related Questions