Due to the way this module is setup, it's not possible to extract field data from fields that are deeper than the first level. (for example, documents that are attached to a node through the media module).

I did a rewrite of the property to make it a configurable property, on the configurable property you can select the indexed file fields to be extracted.

Comments

jeroen.b created an issue. See original summary.

jeroen.b’s picture

Status: Active » Needs review
StatusFileSize
new10.04 KB

Here's a patch.

jeroen.b’s picture

StatusFileSize
new9.98 KB

Sorry, forgot to fix the labels, here's an updated patch.

kholloway’s picture

I am using this patch and it seems to work for indexing files that are nested in media type reference fields on the node. I will update if I discover anything that needs improving.

dakku’s picture

++

Anonymous’s picture

Using this patch to index files attached via paragraphs, seems to work great, thanks.

George Bills’s picture

Works for me, it indexes files attached through media fields. I had to add field_attachments:entity:field_media_file to my index first, then add fields again, then add "saa_file_property" and check the field. @izus any chance of this patch getting rolled into an official release? With media in core now I think it's going to slowly become the "default" for adding files to entities.

izus’s picture

StatusFileSize
new7.08 KB

hi,
Thanks for the suggested patch
i rebased the #3 patch as it was no longer applying.
Here is the rebased patch with no additions. juste a rebase of #3
i'll add the result of my manual test in a separate comment.

izus’s picture

Status: Needs review » Needs work

Hi again,
i tried to evaluate the patch manually before reviewing the code. so i followed the SIMPLE USAGE EXAMPLE section of the readme.

before the patch : it worked like a charm
after applying the patch, it stucks in the 8 step : when trying to add the Search API attachments (saa_file_property) field to the index, the form has an empty required checkboxes field. so the submit can't be passed.

EDIT : as a user, i would hope that required checkboxes field would suggest a list of file fields and media file fields that i want to be indexed

izus’s picture

StatusFileSize
new9.91 KB

as new commits were merged
here is a rebase of the existing patch FWIW but i don't think at now we can use it (explaining in the next comment)

izus’s picture

Title: Unable to index files deeper than first level » Support media (core) module
Category: Bug report » Task
Status: Needs work » Active

i tested the patch in #10 and the result is the same as in #9

we can't go this way as it breacks the work done so far (see #9 for details)

i'm changing this issue title to "Support media module" and setting it back to active

  • izus committed d7903ea on 8.x-1.x
    Issue #2896418 by jeroen.b, izus, kholloway, dakku, samspinoy, George...
izus’s picture

Status: Active » Fixed

Hi
i pushed a commit to handle media file fields.
actually this is working and it supports (for now) the field_media_file media field (this is the default one in media)
search api attachments is now able to add a choice to index this file :)
Thanks all

ps : i'm not going to create a release for this right now, i'll let some weeks pass so that people can test

cirrus3d’s picture

Hi,
How easy could it be to create a D7 version of this patch?
Thank you

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

marco-s’s picture

Hi izus

Thank you very much for this media support. As you said, it currently only supports the default media bundle 'file'. We should add a validation for this in the code, because in my case I have a mixed media field (file bundle and a custom link bundle) which causes an error due the link bundle.

Error: Call to a member function getValue() on null in /search_api_attachments/src/Plugin/search_api/processor/FilesExtractor.php on line 210

Recommended solution:

foreach ($filefield_values as $media_value) {
	$media = Media::load($media_value['target_id']);
        // Supporting only the default media file field for now.
	if ($media->bundle() === 'file') {
		$mediafilefield_values = $media->field_media_file->getValue();
		foreach ($mediafilefield_values as $filefield_value) {
			$all_fids[] = $filefield_value['target_id'];
		}
	}
}
izus’s picture

pushed a commit to adress #16
please feel free to reopen the issue or create a new one if you have another feedback. Also thanks for testing this feature and contributing

netsliver’s picture

StatusFileSize
new928 bytes

indexing error if media is null

izus’s picture

merged #18 Thanks

pcate’s picture

Thank you very much for this media support. As you said, it currently only supports the default media bundle 'file'.

Just an FYI that the "file" media entity type might be renamed to "document": https://www.drupal.org/project/drupal/issues/3019202 in a future core version, so support for other types might become more important.

stefdewa’s picture

I already use media bundle 'Document' instead of 'File'. Attached patch changes only this. This should not be merged in dev because it will break the site of people who have media bundle 'File'. I only upload this for people who already use bundle 'Document'.

Anonymous’s picture

StatusFileSize
new1.82 KB

Above patch no longer applies. Created a new one that supports both "file" and "document" bundle.

izus’s picture

Status: Closed (fixed) » Needs review
Anonymous’s picture

Status: Needs review » Fixed

Just found this https://www.drupal.org/project/search_api_attachments/issues/3048673 so that renders my patch useless.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.