Problem/Motivation

Provides a Search API token field processor
Use case - https://www.morpht.com/blog/announcing-search-api-field-token-module
Contrib module - https://www.drupal.org/project/search_api_field_token

This will also solve #2962569: Index image style URLs

Steps to reproduce

Proposed resolution

Remaining tasks

Issue fork search_api-3273159

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

naveenvalecha created an issue. See original summary.

naveenvalecha’s picture

Status: Active » Needs review
drunken monkey’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs issue summary update

Thanks for suggesting this new feature!
However, there is a lot missing before I can commit this:

  • Most importantly, I’m not convinced this will be useful for enough users to warrant adding this to the module. I’ll therefore wait until several more people have expressed interest/support or are following this issue.
  • The issue summary isn’t very helpful like this. Please elaborate a bit, to enable others to find/understand your proposal.
  • Like all new processors, this would need test coverage.
  • Please do not use MRs in this project, as testing doesn’t work for them – see #3190024: Problem with test dependencies when testing issue forks. Please upload patches instead.
naveenvalecha’s picture

Issue summary: View changes
naveenvalecha’s picture

Issue summary: View changes
naveenvalecha’s picture

naveenvalecha’s picture

naveenvalecha’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs issue summary update
StatusFileSize
new6.46 KB

Updated issue summary + Added tests.

Status: Needs review » Needs work

The last submitted patch, 9: 3273159-9.patch, failed testing. View results

naveenvalecha’s picture

Status: Needs work » Needs review
StatusFileSize
new7.01 KB
naveenvalecha’s picture

Issue summary: View changes
StatusFileSize
new7.97 KB
new1.21 KB

Status: Needs review » Needs work

The last submitted patch, 12: 3273159-12.patch, failed testing. View results

naveenvalecha’s picture

Status: Needs work » Needs review

It was a random failure. I re-tested it. Ready for review.

drunken monkey’s picture

Thanks for adding the tests!
As mentioned, however, I’ll wait until more people express support for this before working further on this.

naveenvalecha’s picture

starfighter1’s picture

I'd like to see this feature. When using search API via headless Drupal, we can only get the URL to a media field with the normal image right now. This is useful for a search teaser image.

There's no clear way to get a URL for an image style from search results data which would be useful for a headless frontend so we don't have to fetch the large uncompressed image.

4alldigital’s picture

I would also be interested in this feature. Having image-styles out of the box would be very useful for all headless app using Drupal as a CMS. This wold negate the usage and integration of additional 3rd party image generation services. I've been using the media style patch for a few years now for this feature.

Thanks for all the work.

naveenvalecha’s picture

Thanks for your feedback, @starfighter1 and @4alldigital
Would you care to RTBC if this works for you

4alldigital’s picture

@naveenvalecha I am not sure what the process it or requirements to "review" and "test", but if you can let me know on here I'll see if I can help. thanks.

naveenvalecha’s picture

@4alldigital
Thanks for your prompt response.
Here's the page which explains how the issue is marked "Reviewed & Tested by community" https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...

eleonel’s picture

Status: Needs review » Reviewed & tested by the community

Working fine for me, looking good.

drunken monkey’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new12.85 KB
new11.14 KB

OK, especially when put together with #2962569: Index image style URLs it does seem like there is enough interest for this to go forward.
Attached is a suggested revision, where I more clearly describe the processor and field. In effect, it’s a processor/field that lets users index custom values, potentially containing tokens. However, I don’t think the previous description really made that clear enough to users not familiar with this ticket.

Still, I expect some confusion amongst users who just spot this field in the “Add fields” dialog, so any suggestions how to make the functionality clearer are welcome.

Finally, I amended the processor and expanded the tests to make sure this also works properly when multiple different types are indexed in the same index.

Please test/review!

Status: Needs review » Needs work

The last submitted patch, 23: 3273159-23--custom_value_processor.patch, failed testing. View results

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new1.71 KB
new11.14 KB

Status: Needs review » Needs work

The last submitted patch, 25: 3273159-25--custom_value_processor.patch, failed testing. View results

naveenvalecha’s picture

Status: Needs work » Needs review
StatusFileSize
new11.1 KB
new649 bytes

This will fix the tests.

Re: #23

+++ b/src/Plugin/search_api/processor/CustomValue.php
@@ -0,0 +1,123 @@
+ *   id = "custom_value",

Thanks for all the great work. The changes look good to me.

Nitpick: custom_value is a generic name. The custom value represents any string value that could be accepted, but we only allow tokenized text. I don't have any strong opinion on the naming, but we should use something like "token_value" or "tokenized_text" or something like that. This is not a blocker for it.

drunken monkey’s picture

Thanks for the test fix!

Nitpick: custom_value is a generic name. The custom value represents any string value that could be accepted, but we only allow tokenized text.

That was exactly my point: we don’t only allow tokenized text, entering a text with tokens in it (for whatever reason) would be completely fine as well.
If we later add options to specify different values per datasource or bundle, this could even become pretty useful completely without tokens.

Anyways, I’m open for other suggestions, but I don’t think we should focus on the tokens this much. First priority is to give users, especially inexperienced ones, a clear idea of what the field will do.
Does anyone else have an opinion on this?

naveenvalecha’s picture

@drunken monkey
Completely satisfied with your thoughts on #28
This looks me ready to be in :)

eleonel’s picture

Status: Needs review » Reviewed & tested by the community

#27 looks good
Thank you

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear. Merged.
Thanks again, everyone!

Status: Fixed » Closed (fixed)

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