Hi There
With a little bit of head scratching I got this module working along with Tika and indexing file contents. The issue I cant figure out is how to get files - which are part of a "Field Collection" indexed. It works great for files directly under nodes and even Profile2 but once the file-field is part of a field collection Tika doesnt get called and I am not sure where to go?
protected function getFileFields() {
$ret = array();
foreach (field_info_fields() as $name => $field) {
if ($field['type'] == 'file' && array_key_exists($this->index->item_type, $field['bundles'])) {
$ret[$name] = $field;
}
}
return $ret;
}
I think it might be to do with "field_info_fields" above - should it look at field_info_bundles or am I on the wrong track?
Any help greatly appreciated.
Comments
Comment #1
osopolar@finmccarthy: Did you go any further on this?
Comment #2
finmccarthy commented@osopolar
Kinda / Sorta - I got it working for the purpose I wanted it - but it was really only by hacking the hell out of the module file and some hardcoding for the specific files that I wanted to index. I am not a programmer and I know that what I have done would horrify most people in the Drupal community but if you are looking for help I can share the file with you (PM me if you want it)
If you are looking to help - I would love to see a cleaner way of doing this.
Kind regards
Fin
Comment #3
izus commentedHi,
For this need, i created a sandbox with a module extending the feature of Search API attachments. The module is called Search API attachments Field collections, and you can find it in https://drupal.org/sandbox/izus/2034837.
Klausi suggested we try adding this feature directly in the Search API attachments module.
So here is a patch against the 7.x-1.x branch, doing mainly what i tried to do in https://drupal.org/sandbox/izus/2034837.
Please give it a try.
I hope this will get in :)
Comment #4
izus commentedto keep it clear, i suggest to mainly add this feature as a submodule. (that will prevent the dependecy on filed collection or the usage of module_exists() and make the code complexe to read and maintain.
i will work on adapting the code of https://drupal.org/sandbox/izus/2034837 to do so.
Comment #5
izus commentedHi,
First quick attempt on this following what i was saying on #4 (integrate it as a submodule)
if you guys can test/review it.
Thanks
Comment #6
hefox commentedInstead of doing anything specific for field collection, this patch creates file contents as a configurable field like file name, mine, size, etc. are. Based on http://ygerasimov.com/add-custom-field-search-api-apachesolr-index
It requires some extra configuration, but looks to be working for node references (node reference field => node => file reference => file contents) when configured to.
It gets rid of the attachment business as that is inflexible though simpler to configure.
edit: if this doesn't work for field collections, my guess is field collections may need a similair intergration to expose them like can do with node references
This likely would best be a 2.x version of this module as upgrade path is non-existant
Comment #7
hefox commentedThis is attempt #1 to combine #6 this patch with #1289222: Allow remote document processing cause I need both
Comment #8
hefox commented...oops
Comment #9
izus commentedok i think that #1289222: Allow remote document processing and #5 can go to the 1.x version after a last review, i just need to manage to have some time testing and understanding #1289222: Allow remote document processing. i'll try it this week and will keep you updated.
i agree changes based on #6 can go to a 2.x version until an upgrade path is provided.
Thanks a lot
Comment #10
izus commentedSo i just updated the patch in #5 after local testings.
I also tested it works without tika as of #1289222: Allow remote document processing
multivalued fields and multivalued field collections are supported too.
I will merge immediately
Comment #11
izus commentedfixed the no newline at end of file notice and merged #10 in 7.x-1.x branch
making this issue status fixed.
Thanks all
Will rename the issue title for #6 and #8 to continue the effort
Comment #12
izus commentedThe new suggested approach in #6 may continue adding patches here if someone wants to work on it and test it fully for node/file/field_colections... when it's ready please ask for a 2.x branch and i'll create it to host the new approach.
Comment #13
sgurlt commentedIs it acutaly possible to search threw field collections? Cause i tried it with the dev release, set the filter on "File attachments Field collections" and added my field collections under the fields tab. But for some reason my files added to the field inside the field collection wont be added to the index.
Comment #14
izus commentedyes, with the sumodule search api attachments field collection enabled, when indexing a node, not only its file fields are indexed but also the file fields of the field collection items it hosts.
Comment #15
sgurlt commentedHmm after trying a lot of things, i cant get this to work.
I've activated the submodule "search api attachments field collections" and added the field collection field to my the fields that should be indexed. After that i've created a view that prints out the index with a filter box on top of it. But for some reason, the content of my files does not get indexed.
Somone got a tipp for me what i might have done wrong?
Comment #16
tekante commentedReroll of patch from 6 to work with the current HEAD of the 1.x branch (22b28144a3c5646d2de5ae5b32ca32d33d383236).
Comment #17
tekante commentedReroll of patch from #6 to work with 7.x-1.4 release.
Comment #19
grimreaperHello,
Is there anything left to be done with this issue?
I see that the last comment is a commit and it was made 10 months ago.
Comment #20
izus commentedactually, there is #6 that suggests another approach adding properties to entities.
nodoby tested yet if it will allow to resolve all the needs for entity references, field collections and others...
The main issues here is solved (field collection), so i'll close this issue and if anybody wants to rework #6 for a 7-2.x version, feel free to open an issue for it. i'll be happy to create a2.x branch that is based on entity properties instead of attachments, but we should test if we can get all the features of 1.x version working in it.
Thanks