This is a bit of an interesting issue. ATM, this module will automatically locate filefield files and files attached using drupal's native file attachment. Pushing other files is not really possible though. In my case, I want to expose documents that are stored by Ubercarts File Downloads module to be indexed. This particular use case is complicated by the fact that Ubercart doesn't use Drupal's file management at all.
The attached patch is a bit of a work in progress that takes a simple approach to solving this problem. There are 2 parts and I'm not sure its the right answer but it seems to be working so far. There is also a reference implementation using uc_file that I'm using for testing.
- It provides an additional hook(I used drupal_alter for simplicity) that allows other modules push file objects into the array of files to be parsed. This works pretty well and Ubercart can work around the reliance on the file fid field by providing a psuedo namespace on its fids.
- It relies on the file url being stored in solr. I kinda dislike this part of the patch since it means you'll have to re-index to get any Drupal filehandling changes but D6 file handling is so wonky you've got to jump through 50 hoops to do that anyways and I'm not sure it was better before.
I'm marking this as needs review but its very likely in need of work. Its a rough implementation that I'm still testing on our dev machine.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 775644-13.apachesolr_attachments.patch | 20.77 KB | csevb10 |
| #11 | 775644-11.apachesolr_attachments.patch | 20.77 KB | csevb10 |
| #8 | 775644-8.apachesolr_attachments.patch | 20.9 KB | csevb10 |
| #7 | apachesolr_attachements.patch | 20.24 KB | rapsli |
| #6 | 775644-apachesolr_attachments-support-multiple-backends.patch | 19.88 KB | neclimdul |
Comments
Comment #1
neclimdulwoops, forgot to finish the title.
Comment #2
pwolanin commentedI don't want to index the result of file_create_url().
A better option is to follow Drupal 7's version and we should either re-implement the Drupal 6 version, or wrap the druapl 6 version with anither function that also calls drupal_alter()
Comment #3
neclimdulok another stab. I haven't had a chance to test this but looking for conceptual feedback to make sure its the right idea.
Comment #4
pwolanin commentedlooks like on the right track, but this change should use the new function too:
Comment #5
neclimdulActually it uses it in building the output in
apachesolr_attachments_apachesolr_process_results()but that line is building the document to send to solr so that result would be indexed.Though, looking over it fresh in the morning, it should probably go back to $file->filepath? But since the next line is actually storing that maybe its not necessary... Don't know I'll float around IRC and we can talk it through if you want.
Comment #6
neclimdulUpdated patch built on top of #561862
Comment #7
rapsli commentedupdated patch to latest head version, as it wouldn't apply anymore. Going to do some testing now, so we can get this into the module. I hope this is the goal?
Comment #8
csevb10 commentedOk. I made a few modifications, predominately to support multisite functionality.
It'd be good now to get another set of eyes back on this (neclimdul?) to see if what I've done here still works for your use cases in production.
Comment #9
pwolanin commentedA quick pass looks reasonable - some minor comments:
It might make more sense for this to be an alter hook?
In any case, I'd rather see $files['upload'] and $files['filefield'] than $files['drupal']
Comment #10
neclimdulI think I grouped those two items into 'drupal' because they use the same backend and other parts of the code would have to be reworked to support them.
That said, that may be a argument for providing an alter hook, though personally it seems like it would be better in addition to rather than in replacement of the hook.
Comment #11
csevb10 commentedHere's a version simply switching the file types.
The only issue I can see with this is that a later hook (apachesolr_attachments_url) is based off of the file type. So, if you wanted to do the same thing to filefield elements and upload module elements, you'd now need 2 separate hooks. I think that's reasonable.
If this isn't sufficient, I can roll another version switching to drupal_alter.
Comment #12
pwolanin commentedInstead of 'file_type' maybe we should call this 'module' or or 'file_module'? It's not the file type at all.
Comment #13
csevb10 commentedUpdated from file_type to file_module and modified existing text to be more logical.
Comment #14
pwolanin commentedOne significant concern. For the update function:
needs to be 'upload'? But some will actually be 'filefield'?
Some minor nits:
This doxygen needs better formatting:
this code comment is unneeded:
?
Comment #15
topdillon commentedI am currently using 7.x-1.2. Is there any hope of this patch working for me?