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).

CommentFileSizeAuthor
#8 848756-8.patch2.69 KBjpmckinney
#6 848756-6.patch1.43 KBjpmckinney
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

awakenedvoice’s picture

Subscribing

wmostrey’s picture

Robert wrote a complete guide with an example module on how to do this: Understanding the ApacheSolr CCK API

wmostrey’s picture

Should we include Robert's custom module (and use this issue), or keep it as a guide (and close this issue)?

jpmckinney’s picture

I think we should leave it as a guide.

pwolanin’s picture

I'd be happy to roll the code in some day, but is not a priority for me at the moment.

jpmckinney’s picture

FileSize
1.43 KB

I wrote the code for the 7.x port, but following Robert's guide actually creates a facet for nodes, not for files, FYI.

jpmckinney’s picture

For 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.

jpmckinney’s picture

FileSize
2.69 KB

Old fashioned alternative (for D7).

pwolanin’s picture

For D7 I expect some major refactoring yet around entity indexing and handling.

jpmckinney’s picture

Status: Active » Needs review

#8 is the patch to review.

wmostrey’s picture

Status: Needs review » Needs work

1. Function apachesolr_default_server() is replace by variable_get('apachesolr_default_server', 'solr');
2. Function apachesolr_get_enabled_facets() also doesn't exist anymore. We do have variable_get('apachesolr_enabled_facets', NULL); and facetapi_get_enabled_facets().

wmostrey’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
bleedev’s picture

An implementation of Facet API to provide for a mimetype Solr facet and filter block I wrote up here.

wmostrey’s picture

That's a great article Brandon, thanks. Using file_mimetype_mapping() we could add an automatic filter for each mime, showing the file extension.

zilla’s picture

it 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

Nick_vh’s picture

Please refactor this patch so it works in the latest D7 code :-)

David_Rothstein’s picture

If 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