jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Jetpack Search: Taxonomy filters not displaying

Open ecairol opened this issue 4 years ago • 18 comments

Impacted plugin

Search

Steps to Reproduce

  1. Go to https://tspa-iss-1219.mystagingwebsite.com/explore/resource-library/
  2. Enter a keyword on the Search input (eg: "safety" returns valid results)
  3. Check out the filters on the right panel

A clear and concise description of what you expected to happen.

A taxonomy filter for Categories should be displayed

What actually happened

A list of filters for Date and Post Type is displayed, but not the filter for Categories.

Other information

  • This happens for custom taxonomies as well. For all taxonomies actually.
  • On the Production site, it happens only for custom taxonomies but not for Categories
  • Could potentially be related to this old issue reported here.
  • On the cloned test site, there was a taxonomy rename that required SQL updates. However, the issue is also replicable in Production where none of these changes have taken place yet.

Below are screenshots of the configuration:

Screen Shot 2022-06-09 at 15 38 01 Screen Shot 2022-06-09 at 15 40 23

Operating System

macOS

OS Version

11.6.5

Browser

Chrome/Chromium

Browser Version(s)

100.0.4896

ecairol avatar Jun 09 '22 21:06 ecairol

Hi @ecairol thanks for reporting this. I think the issue is because we don't support all taxonomies, and another bug report could be found here.

Would you please try to remove all customized taxonomies and leave only category and tag and see if it works? so that we can confirm the issue. Thanks.

Also hi @gibrown, are you able to provide some suggestions on how we could resolve this? Thanks. I'm thinking potentially we should at least hide the unsupported taxonomies from the widget taxonomy dropdown.

Cheers

cc @Automattic/jetpack-search

kangzj avatar Jun 13 '22 01:06 kangzj

@kangzj @gibrown thanks, let me try that out today and I'll confirm with you here.

ecairol avatar Jun 13 '22 14:06 ecairol

@kangzj ya the full list of taxonomies is available so limiting what the user can select would be a good fix here.

gibrown avatar Jun 13 '22 17:06 gibrown

@gibrown @kangzj that would be a great UX.

What's the feature that makes a taxonomy supported or not for the filter panel? Is it all custom taxonomies?

ecairol avatar Jun 13 '22 21:06 ecairol

@ecairol Search explicitly synced taxonomies could be found here:

https://github.com/Automattic/jetpack/blob/64ce40fcd3fc2def48ba7b8f49b5712280cd2ddf/projects/packages/sync/src/modules/class-search.php#L683

And also taxonomies registered on the site: https://github.com/Automattic/jetpack/blob/64ce40fcd3fc2def48ba7b8f49b5712280cd2ddf/projects/packages/sync/src/class-functions.php#L41

Black listed: https://github.com/Automattic/jetpack/blob/64ce40fcd3fc2def48ba7b8f49b5712280cd2ddf/projects/packages/sync/src/class-defaults.php#L427

kangzj avatar Jun 13 '22 22:06 kangzj

@ecairol Also what plugin registers the customized taxonomies you are using? I might have a play and see. 😄

kangzj avatar Jun 13 '22 22:06 kangzj

@kangzj wow that's quite a list!

The customized taxonomies are registered via code, eg:

register_taxonomy(
	'tspa-resources-topic',
	self::POST_TYPE,
	array(
		'label'             => __( 'Topic', 'tspa' ),
		'description'       => __( 'The resource topic to be grouped under.', 'tspa' ),
		'public'            => true,
		'hierarchical'      => true,
		'show_admin_column' => true,
	)
);

I noticed that at the end of $taxonomies_to_sync list there are a few exceptions made for End The Backlog (which is another site maintained at Special Projects), so I wonder if we could make another exception and add these three to that whitelist?

  • tspa-resources-topic
  • tspa-resources-type
  • tspa-curriculum-type

ecairol avatar Jun 14 '22 14:06 ecairol

@ecairol spun up a diff to add the three taxonomies: D82983-code

kangzj avatar Jun 22 '22 04:06 kangzj

@ecairol Also, feel free to use jetpack-search-tag0 - jetpack-search-tag9 which are already supported for custom taxonomies. 😄

I'll spun another PR to limit the list shown in the drop down, so that users would know, we don't support all taxonomies.

kangzj avatar Jun 22 '22 04:06 kangzj

Also, feel free to use jetpack-search-tag0 - jetpack-search-tag9

Thank you very much @kangzj - I think I'll wait for the three taxonomies to be added, just to keep it semantically clear. But I'll keep that in mind for the future.

D82983-code

I'm getting a "You Shall Not Pass: Restricted Differential Revision" message when I visit D82983-code – ~Do you know if there's a way for me to keep track of when this is released? Or an estimated date?~ I guess I can check the Changelog in a week or so and I'd see the change listed there?

I'll spun another PR to limit the list shown in the drop down, so that users would know

That sounds good, yes! Thanks

ecairol avatar Jun 22 '22 14:06 ecairol

Hi @ecairol the requested taxonomies are now supported thru D82983-code, would you mind doing a full sync and see how it goes?

An important thing to note: We are about to only show the officially supported taxonomies from the next release of Jetpack and Search plugins. You'll need to hook a filter to add customized taxonomies for the dropdown. Examples please see: https://github.com/Automattic/jetpack/pull/24823.

If you've got more questions/issues, please just let us know. Thanks.

kangzj avatar Jul 12 '22 02:07 kangzj

@kangzj thank you for the heads up.

What do you mean by "doing a full sync" ?


Context: There's something missing on my side but I'm not sure what. Currently using Jetpack Version 11.2-a.3

I've implemented the jetpack_search_supported_taxonomies on our test site, however, I still cannot see the custom taxonomies on the dropdown. I've also added a die() to see if the execution stops inside the filter, but it didn't.

add_filter(
	'jetpack_search_supported_taxonomies',
	function( $taxonomies ) {
		$taxonomies[] = 'tspa-resources-topic';
		$taxonomies[] = 'tspa-resources-type';
		$taxonomies[] = 'tspa-curriculum-type';
		return $taxonomies;
	}
);

The Taxonomy dropdown is now only showing a limited number of options, so I suspect I've got your latest changes, but not the custom taxonomies:

Screen Shot 2022-07-15 at 13 06 14

Thanks in advance for any hint you can provide

ecairol avatar Jul 15 '22 19:07 ecairol

the requested taxonomies are now supported thru D82983-code, would you mind doing a full sync and see how it goes?

@kangzj can you please clarify what you mean by doing a full sync?

ecairol avatar Jul 19 '22 20:07 ecairol

@ecairol you can schedule a full sync from the Jetpack debugger:

https://jptools.wordpress.com/debug/?url=https://tspa-iss-1219.mystagingwebsite.com

I've just scheduled one for you.

bluefuton avatar Jul 19 '22 22:07 bluefuton

Hi @ecairol sorry I was afk for a couple of days. And sorry again, the filter nam was changed to "jetpack_search_allowed_taxonomies_for_widget_filters" in the end. Could you please try it out and see? Thanks

kangzj avatar Jul 20 '22 07:07 kangzj

Thank you @bluefuton this is new for me, I've made note for future reference.

No worries @kangzj, thanks for the clarification.

-- Update: worked like a charm! Thanks!

ecairol avatar Jul 20 '22 13:07 ecairol

Did this functionality for adding custom taxonomies stop working?

I have:

add_filter(
	'jetpack_search_allowed_taxonomies_for_widget_filters',
	function( $taxonomies ) {
		$taxonomies[] = 'tnc_tax_51091';
		$taxonomies[] = 'tnc_tax_53440';
		return $taxonomies;
	}
);

and I did a jetpack debug on the site which above said refreshes the index but these taxonomies have never shown up.

Also, I think I am asking for the correct thing. The issue is that the custom post types do not show up at all in the search. When I had looked into this before I saw this filter as well for the post types which I also have registered. But I can not even find a reference to this filter now:

add_filter( 'jetpack_search_post_types', function( $post_types ) {
    $post_types[] = 'tnc_col_50901_item';
	$post_types[] = 'tnc_col_55294_item';
    return $post_types;
} );

AaronNewcomer avatar Jun 29 '24 19:06 AaronNewcomer

Seems to be related: panfyZ-3QN-p2

kangzj avatar Jul 02 '24 01:07 kangzj