There are at least two ways to approach this:
1.) If you want the user to understand why a search result showed up, you should turn on the highlighting and snippet features (see searches.ini). The major limitation to using snippets is that Solr will only show snippets from fields that are designated as "stored" in the schema. The "allfields" field is not stored because retrieving too much stored data in search results can cause PHP to run out of memory, and the allfields field has the potential of being extremely large. However, you can always add custom indexing rules to put your TOC data into a stored field if that is not already happening. Once that is done, you can customize the SolrDefault record driver if you need to adjust the displayed caption for the TOC snippet. (I don't think this much customization is necessary, though -- there is already a stored "contents" field holding 505a/505t; if your TOC is somewhere else, you may just need to index it into contents to get the desired functionality).
2.) Although it doesn't help the user understand results, if you get a question about a set of results and need to explain them, you can turn on debug in VuFind, perform the search, copy the URL of the Solr query, add "&debugQuery=true" onto the end, and then see detailed explanations of how every relevance calculation was performed. This comes in really handy sometimes.
From: Daniel Zimmel [zimmel@...]
Sent: Friday, September 28, 2012 6:43 AM
Subject: [VuFind-Tech] determine which value produced a hit in Solr?
does anybody know if Solr can tell us the field which produced the hit?
I didn't find anything useful on the documentation.
I guess it is not implemented in Solr because it might be too complex to
analyze or decide all the possible cases and you might end up in chaos. Am I
We put our extracted table of contents data in one MARC field, which gets
indexed for AllFields search. This is fine, but for our user it is not
obvious why she should select a title if there is no clear connection with
her search terms.
So it might be useful to show her in the results list that she got this hit
because her terms are indexed in the table of contents.
Sorry if this idea sounds silly from a developer perspective, but I am just
a librarian pushing data around.
Daniel Zimmel Tel. +49 228 91416-17
Erforschung von Gemeinschaftsgütern, Bonn ||/| Bibliothek