Hi, *Quick context of the application first.*
I am currently using Solr in standalone mode to index thousands of text-like documents (not exactly textual documents). A single document has a structure like following: - *id* - unique file id - *line_text* - textual data - *file_local_url* - file's directory location path - *line_no* - line number of the line_text *What I am trying to achieve?* After I search on the line_text field, as a result I should see the matching text snippets. A text snippet can be the lines from (line_no - 3) to (line_no + 3). Currently for search front-end I am using Solr's in-built Velocity response writer and its templates. *How I am thinking of doing this?* I am using the default Velocity templates which are shipped with Solr. In the template file hit.vm, following is the way it currently fetches, processes and displays the responses: #foreach( $fieldName in $doc.fieldNames ) <tr> <th align="right" valign="top" style="field-name"> $esc.html($fieldName): </th> <td align="left" valign="top"> #field($fieldName) </td> </tr>#end Now to get the snippet text I would like to define an external function somewhere in a Java class something of this form: public String getSnippet(file_local_url, line_no) which will return the snippet in a string format. Now I want to consume this response in the velocity template. There I am thinking of something like this: ## get the snippet string by calling the external ava function #set($snippet = $someClass.getSnippet(#field("file_local_url"), #field("line_no))) ## print the snippet snippet (I am not sure if this is the correct syntax.) *Questions:* 1. What kind of file should contain someClass.getSnippet()? Java file? Class file? A jar? 2. Where should I keep this file? How will velocity know where to find this class? 3. Am I using the write syntax to call the method and use its results in above Velocity template? I am quite not getting the bigger picture yet (especially the question 2 above). Please provide some direction. Thanks. Ravi. -- What if the cure for cancer is trapped inside the mind of someone who can't afford an education? - anonymous