1
votes

I want to use VelocityResponseWriter in solr.

I've indexed a website( for example xxxx://www.biginfolabs.com/). If i type a query xxxx://localhost:8983/solr/collection1/select?q=santhos&wt=xml&indent=true I will get all the fields related to that document (content,host,title,url etc) but if i put the query in velocity xxxx://localhost:8983/solr/collection1/browse?q=santhosh i will see only 3 fields(id,url,content) instead of all other fields.

How can i display all the fields??

This is in solrconfig.xml

<requestHandler name="/browse" class="solr.SearchHandler">
 <lst name="defaults">
   <str name="echoParams">explicit</str>

   <!-- VelocityResponseWriter settings -->
   <str name="wt">velocity</str>
   <str name="v.template">browse</str>
   <str name="v.layout">layout</str>
   <str name="title">Solritas</str>

   <!-- Query settings -->
   <str name="defType">edismax</str>
   <str name="qf">
      text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
      title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
   </str>
   <str name="df">text</str>
   <str name="mm">100%</str>
   <str name="q.alt">*:*</str>
   <str name="rows">10</str>
   <str name="fl">*,score</str>

   <str name="mlt.qf">
     text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
     title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
   </str>
   <str name="mlt.fl">text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename</str>
   <int name="mlt.count">3</int>

   <!-- Faceting defaults -->
   <str name="facet">on</str>
   <str name="facet.field">cat</str>
   <str name="facet.field">manu_exact</str>
   <str name="facet.field">content_type</str>
   <str name="facet.field">author_s</str>
   <str name="facet.query">ipod</str>
   <str name="facet.query">GB</str>
   <str name="facet.mincount">1</str>
   <str name="facet.pivot">cat,inStock</str>
   <str name="facet.range.other">after</str>
   <str name="facet.range">price</str>
   <int name="f.price.facet.range.start">0</int>
   <int name="f.price.facet.range.end">600</int>
   <int name="f.price.facet.range.gap">50</int>
   <str name="facet.range">popularity</str>
   <int name="f.popularity.facet.range.start">0</int>
   <int name="f.popularity.facet.range.end">10</int>
   <int name="f.popularity.facet.range.gap">3</int>
   <str name="facet.range">manufacturedate_dt</str>
   <str name="f.manufacturedate_dt.facet.range.start">NOW/YEAR-10YEARS</str>
   <str name="f.manufacturedate_dt.facet.range.end">NOW</str>
   <str name="f.manufacturedate_dt.facet.range.gap">+1YEAR</str>
   <str name="f.manufacturedate_dt.facet.range.other">before</str>
   <str name="f.manufacturedate_dt.facet.range.other">after</str>

   <!-- Highlighting defaults -->
   <str name="hl">on</str>
   <str name="hl.fl">content features title name</str>
   <str name="hl.encoder">html</str>
   <str name="hl.simple.pre">&lt;b&gt;</str>
   <str name="hl.simple.post">&lt;/b&gt;</str>
   <str name="f.title.hl.fragsize">0</str>
   <str name="f.title.hl.alternateField">title</str>
   <str name="f.name.hl.fragsize">0</str>
   <str name="f.name.hl.alternateField">name</str>
   <str name="f.content.hl.snippets">3</str>
   <str name="f.content.hl.fragsize">200</str>
   <str name="f.content.hl.alternateField">content</str>
   <str name="f.content.hl.maxAlternateFieldLength">750</str>

   <!-- Spell checking defaults -->
   <str name="spellcheck">on</str>
   <str name="spellcheck.extendedResults">false</str>      
   <str name="spellcheck.count">5</str>
   <str name="spellcheck.alternativeTermCount">2</str>
   <str name="spellcheck.maxResultsForSuggest">5</str>      
   <str name="spellcheck.collate">true</str>
   <str name="spellcheck.collateExtendedResults">true</str> 
   <str name="spellcheck.maxCollationTries">5</str>
   <str name="spellcheck.maxCollations">3</str>          
 </lst>

 <!-- append spellchecking to our list of components -->
 <arr name="last-components">
   <str>spellcheck</str>
 </arr>
  </requestHandler>
1

1 Answers

0
votes

The reason you don't see all the fields in your search results is because the response is post-processed by the VelocityResponseWriter. Take a look at the VM template files in located in your solr_server_home/solr/collection_name/conf/velocity.

In the version of Solr that I'm working with (4.9.0), the VM template richtext_doc.vm controls the output of each result, and it outputs only the id,url,content fields.

Lets say you have a field called "Country", you could add the following content to the richtext_doc.vm to display the Country field.

## Country 
#if($doc.getFieldValue('Country'))
  <div>
    Country:
    #field('Country')
  </div>
#end