Download & Extend

Add new facet for document type (or extension)

Project:Apache Solr Attachments
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

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

Comments

#1

Subscribing

#2

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

#3

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

#4

I think we should leave it as a guide.

#5

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

#6

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

AttachmentSize
848756-6.patch 1.43 KB

#7

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.

#8

Old fashioned alternative (for D7).

AttachmentSize
848756-8.patch 2.69 KB

#9

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

#10

Status:active» needs review

#8 is the patch to review.

#11

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

#12

Version:6.x-1.x-dev» 7.x-1.x-dev

#13

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

#14

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

#15

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

#16

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