0

I am using Solr 5.4 and have Solr schema containing 5 fields. Now, I am indexing two types of docs:

Doc1:
    field1
    field2
    field3
Doc2:
    field1
    field4
    field5

Here field1 contains unique ID and it is common to both the docs. There are more docs of type Doc2 than Doc1. Since field2 contains large amount of text, I cannot duplicate field2 for each Doc2. Now I want to retrieve field2 also while querying for doc type Doc2 using field1. Is it possible to do so?

Vivek
  • 75
  • 1
  • 9
  • Take a look at nested objects in solr: http://yonik.com/solr-nested-objects/ in your case the Doc1 could be a parent to Doc2 – D_K Mar 02 '16 at 09:29
  • Have you tried with grouping? Search and Group on field1 and you should have both docs 1 and 2 with whatever fields you need specified using the fl parameter. – Binoy Dalal Mar 04 '16 at 10:45
  • @D_K how can I get parent fields in result doc of child type? – Vivek Mar 28 '16 at 06:33
  • @Binoy Dalal This will work for single doc2 with field1 query. how can I map multiple doc2 with different field1 values while querying? – Vivek Mar 28 '16 at 06:36
  • This will return all the Doc2s that match that particular field1 value, not just a single one. I don't understand what you mean when you say "how can I map multiple doc2 with different field1 values while querying?" – Binoy Dalal Mar 28 '16 at 13:23
  • @Vivek check this out: https://github.com/lucidworks/solrj-nested-docs – D_K Mar 29 '16 at 04:49
  • @Binoy Dalal. I will be querying Doc2 not on field1 but on another field say: field4 or field5. How will I get field2 in each of my result Docs? – Vivek Mar 29 '16 at 05:58
  • @D_K In the example given in NestedDocs2.java (eDismax + Parent / Child Join), query is done for parent documents and child documents are joined afterwards. Can you give an example where reverse process is done i.e query for child documents( say make_t field) and then join parent fields after that?. --Thanks – Vivek Mar 29 '16 at 10:01
  • Perhaps [this](https://wiki.apache.org/solr/Join) can help you out. – Binoy Dalal Mar 29 '16 at 17:40
  • @Binoy Dalal. It will only return docs of type Doc1 having matching field1 in docs type Doc2 after join operation. – Vivek Mar 30 '16 at 10:51
  • Here's one alternative that will most certainly work in case you are unable to find a direct way of doing this. Fire the first query to find all Doc2s. Then use the Field1 values from Doc2s and fire another query to get all the Field2 values from Doc1s. – Binoy Dalal Mar 30 '16 at 18:22
  • Additionally, I would suggest you also post this in the solr users forum. It's and interesting question and you'll be able to get help quickly. – Binoy Dalal Mar 31 '16 at 18:31
  • @Binoy Dalal. Ok sure – Vivek Apr 01 '16 at 06:47

0 Answers0