0

I have 8 fields in my schema. I have 2 types of documents in the index. The first type contains the details of a book and the second type of document contains where all a particular book is referenced.

The reason for such a schema is to reduce the index size. The documents in my Solr index look like this -

doc1 -
uniqueKey - <someid>
id - 1
name - Solr
author - something
isbn - something else
subject - null
referenced - null
dataType - detail

doc2 -
uniqueKey - <someid>
id - 1 
name - null
author - null
isbn - null
subject - physics
referenced - 2011
dataType - reference

doc3 -
uniqueKey - <someid>
id - 1 
name - null
author - null
isbn - null
subject - maths
referenced - 2013
dataType - reference

I want to let my users choose the subject and/or year but display the detail document in the result.

To achieve this I use the join query which looks like -

q=dataType:detail&fq={!join from=id to=id}<userySelectedSubjectAndOrYear>&dataType:reference

I have to generate this query in my backend everytime; instead I would like to use default, appends and/or invariant in my requestHandler because most part of the query remains the same.

I tried to do the following in my requestHandler

<requestHandler name="/usage" class="solr.SearchHandler">
 <lst name="defaults">
   <int name="rows">10</int>
   <str name="wt">json</str>
 </lst>
 <lst name="appends">
   <str name="q">dataType:detail</str>
   <str name="fq">{!join from=id to=id}dataType:reference</str>
 </lst>
</requestHandler>

and pass the user selected subject and/or year as /usage?fq=subject:physics I do not get any results. According to the link, it should append the values. What am I missing? Will I have to write my own custom RequestHandler to get this?

JHS
  • 7,761
  • 2
  • 29
  • 53
  • Do you get any results if you build the URL yourself? Have you looked at the response to see what the URL generated internally after parsing is? I think I'd also try to avoid relying on join, and instead index the genre and year for each reference to each book. – MatsLindh Aug 31 '14 at 15:13
  • @MatsLindh - I do get the required output when I request using the URL. I had 2 options 1. to have the genre and year as multivalued but it creates a cross join. 2. The other fields name, author and ISBN have other tokenizers and filters so if I have the data in all records then the index size increases considerably. – JHS Sep 01 '14 at 08:03
  • But what is the difference of the parsed parameters in the resposne when using the URL directly and using the appended version? The response from Solr includes a list in the response. Regarding the data structure, there shouldn't be a need for a join if you use multivalued fields to keep the year/genre/year:genre, and no need to duplicate data for the other fields. – MatsLindh Sep 01 '14 at 09:20

0 Answers0