Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It's an obvious feature to want to be able to filter by document type.
That could take a few forms:
MIME type (likely ugly)
some groups based on MIME type
the file extension (annoying for jpeg vs jpeg, etc).
Comment | File | Size | Author |
---|---|---|---|
#8 | 848756-8.patch | 2.69 KB | jpmckinney |
#6 | 848756-6.patch | 1.43 KB | jpmckinney |
Comments
Comment #1
awakenedvoice CreditAttribution: awakenedvoice commentedSubscribing
Comment #2
wmostrey CreditAttribution: wmostrey commentedRobert wrote a complete guide with an example module on how to do this: Understanding the ApacheSolr CCK API
Comment #3
wmostrey CreditAttribution: wmostrey commentedShould we include Robert's custom module (and use this issue), or keep it as a guide (and close this issue)?
Comment #4
jpmckinney CreditAttribution: jpmckinney commentedI think we should leave it as a guide.
Comment #5
pwolanin CreditAttribution: pwolanin commentedI'd be happy to roll the code in some day, but is not a priority for me at the moment.
Comment #6
jpmckinney CreditAttribution: jpmckinney commentedI wrote the code for the 7.x port, but following Robert's guide actually creates a facet for nodes, not for files, FYI.
Comment #7
jpmckinney CreditAttribution: jpmckinney commentedFor D7, the issue is with apachesolr_entity_fields. You can pass it an $entity_type, but for search it will almost always be "node". And the fields that field_info_fields() returns will usually be tied to only the node bundle. I don't think it makes sense to create a "file" bundle just to make it easier for apachesolr_attachments to implement facets. So, implementing hook_apachesolr_field_mappings, which apachesolr_entity_fields calls, can only really add facet fields for node documents, not file documents. I can create a facet the old-fashioned way, just putting down these thoughts in case someone has a better idea.
Comment #8
jpmckinney CreditAttribution: jpmckinney commentedOld fashioned alternative (for D7).
Comment #9
pwolanin CreditAttribution: pwolanin commentedFor D7 I expect some major refactoring yet around entity indexing and handling.
Comment #10
jpmckinney CreditAttribution: jpmckinney commented#8 is the patch to review.
Comment #11
wmostrey CreditAttribution: wmostrey commented1. Function
apachesolr_default_server()
is replace byvariable_get('apachesolr_default_server', 'solr');
2. Function
apachesolr_get_enabled_facets()
also doesn't exist anymore. We do havevariable_get('apachesolr_enabled_facets', NULL);
andfacetapi_get_enabled_facets()
.Comment #12
wmostrey CreditAttribution: wmostrey commentedComment #13
bleedev CreditAttribution: bleedev commentedAn implementation of Facet API to provide for a mimetype Solr facet and filter block I wrote up here.
Comment #14
wmostrey CreditAttribution: wmostrey commentedThat's a great article Brandon, thanks. Using file_mimetype_mapping() we could add an automatic filter for each mime, showing the file extension.
Comment #15
zilla CreditAttribution: zilla commentedit seems that simply "has attachment" would be the logical facet to add (filter out search results for all nodes with attachments upon word search)
further facet by filetype would be awesome - but seems like it should be conditional upon first even having an attachment
Comment #16
Nick_vhPlease refactor this patch so it works in the latest D7 code :-)
Comment #17
David_Rothstein CreditAttribution: David_Rothstein commentedIf you're using the File Entity module to define file types, I believe this (mostly) works already - those types will appear as options in the bundle facet just like any other entity bundles. However, see related issue: #2014675: Support for filtering by file type using the Facet API is incomplete