Closed (fixed)
Project:
Apache Solr Search
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Sep 2012 at 23:34 UTC
Updated:
12 Oct 2012 at 10:40 UTC
Jump to comment: Most recent file

Comments
Comment #1
grendzy commentedSince apachesolr stores text html-encoded (not sure why, but it does), it needs to be decoded before rendering (see the source of apachesolr_l()).
This patch uses html_entity_decode() instead of the Drupal equivalent function, following the example in apachesolr_l().
Comment #1.0
grendzy commentedfix php
Comment #2
cpliakas commentedHi grendzy.
Thanks for the detailed steps on how to reproduce this issue and the excellent debugging. My one comment on this patch, though, is that I don't want to make assumptions in Facet API based on the backend. For example, if the core Search module doesn't return encoded HTML strings, than it should not run through a link function that decodes html elements to account for how Apache Solr stores it's values.
What I would recommend is creating a "map callback" for your facet to act on the values accordingly. For example, modify your snippet using the code below:
This will have the benefit of decoding the HTML entities only for the effected facet.
Thanks,
Chris
Comment #3
grendzy commentedThanks for the thoughtful reply, I wasn't aware of the implications for non-solr backends. I'd like to leave this open as a documentation issue for the moment, if that's OK. I'll try to study a bit more with the goal of a documentation or handbook patch.
BTW, do you know if the
hook_facetapi_facet_info()is necessary in this case, or is there an alternative way to make text facets visible through the apachesolr module (since it implements the facetapi hook as well)? The reason I ask is while I agree the map callback a a straightforward fix, it seems like a leaky abstraction, I wouldn't expect to be handling encoding at such a high level.Comment #4
cpliakas commentedgrendzy,
Sounds good. I will leave it open.
Regarding hook_facetapi_facet_info(), Apache Solr Search Integration does have a higher level hook which defines all Solr fields, and then implements hook_facetapi_facet_info() automatically. Check out the hook_apachesolr_field_mappings() implementations for examples of how this is done. Some of the keys are simply passed along to Facet API, for example the "query type" and "map callback" keys just to name a couple. This way you can define a field that is available to Apache Solr Search Integration and expose it as a facet all in one shot.
Hope this helps,
Chris
Comment #5
grendzy commentedI found the relevant documentation is in apachesolr.api.php.
I couldn't think of a sensible way to document this without actually adding a callback to the module, so this patch includes a new function:
apachesolr_string_facet_map_callback().Comment #6
nick_vhI don't think this should be in the main module but in a custom module of your own? I am going to close this one but it is very useful for future references as I can imagine more people will have similar questions.
Comment #7
grendzy commentedThanks for the feedback, would you consider a documentation-only patch to apachesolr.api.php?
As it's written, I think the documentation for
hook_apachesolr_field_mappings_alter()is incorrect. If a user follows the documentation to "Enable indexing for text fields" this problem will occur every time. It's also a costly problem to debug (it took me about 12 hours to get to the bottom of it).Comment #8
nick_vhI'd surely consider an API only patch. Feel free to provide one, with a link to this issue.
Comment #9
nick_vhClosing this as fixed since the solution is here but no documentation patch was written. At least people can find it here :)
Comment #9.0
nick_vhadd missing cron step