Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ElasticSearch/Jetpack to customize search #44

Merged
merged 4 commits into from
Aug 18, 2021
Merged

Conversation

iandunn
Copy link
Member

@iandunn iandunn commented Feb 19, 2021

@iandunn iandunn added [Type] Enhancement New feature or request [Component] Pattern Directory API The pattern API on WordPress.org, and/or the CPT endpoint [Component] Pattern Directory The backend of the pattern directory: submission, management, etc labels Feb 19, 2021
@iandunn iandunn self-assigned this Feb 19, 2021
@iandunn
Copy link
Member Author

iandunn commented Feb 19, 2021

so far this is fairly straightforward, but i'll know more once the access is setup on the jetpack/es side

fyi @dd32, @tellyworth

@ryelle
Copy link
Contributor

ryelle commented Jul 12, 2021

@iandunn What's the status of this PR/issue #28? Our initial launch deadline is Friday, since we're aiming to be stable by 5.8's release next Tuesday (20th). Will we have ElasticSearch support by then?

@iandunn
Copy link
Member Author

iandunn commented Jul 12, 2021

Oh, I never saw that the website had a deadline tied to the Core release; it's unlikely this will be done by then. I'm AFK Thursday/Friday too.

I'm guessing using regular WP search will be performant with the small number of patterns we have now, but the quality of the results will be poor because of post content being included instead of descriptions.

It'd potentially be faster to create a meta field with index terms as a temporary measure, but I'd lean towards just focusing on getting this done soon.

@ryelle
Copy link
Contributor

ryelle commented Jul 12, 2021

Okay, it sounds like that's acceptable for the initial launch, since the api.w.org only serves a subset of patterns. Moving #28 out of Initial Launch.

@iandunn iandunn requested a review from tellyworth August 11, 2021 15:04
@iandunn
Copy link
Member Author

iandunn commented Aug 11, 2021

@tellyworth , @gibrown, @earnjam: This is mostly working, and ready for review if you have any thoughts.

I think the last bits are boosting the title over the description, and including the en_US fallback patterns. Those shouldn't impact the overall architecture, etc though. I'll keep working on those.

I've got e2e tests on my sandbox that I can commit to meta.svn once this is merged.

@iandunn
Copy link
Member Author

iandunn commented Aug 11, 2021

f23323e boosts the primary locale in some cases, but not enough to make them always appear before the en_US fallback. The latter is how the directory behaves for browsing, but maybe in a search context we want still want the relevancy to override locale in some cases?

If not, maybe a sort would be a better approach than boosting?

@iandunn iandunn marked this pull request as ready for review August 18, 2021 15:16
@iandunn iandunn merged commit 2e72623 into trunk Aug 18, 2021
@iandunn iandunn deleted the 28-elasticsearch branch August 18, 2021 15:18
bazza pushed a commit to WordPress/wordpress.org that referenced this pull request Aug 18, 2021
@iandunn
Copy link
Member Author

iandunn commented Aug 18, 2021

@iandunn
Copy link
Member Author

iandunn commented Aug 19, 2021

@earnjam: most of the w.org mu-plugins are still closed-source, but here's a copy of the one that search.php relies on, in case it's helpful for the theme directory.

<?php

namespace WordPressdotorg\Pattern_Directory\MU_Plugin;

/*
 * Most of the site functionality is in `wp-content/plugins/pattern-*`, but some things are more appropriate for
 * an mu-plugin, or need to be done before plugins are loaded.
 *
 * We don't have a paid Jetpack plan, so the Search feature would normally be off. The Jetpack team has manually
 * created custom indexes for Patterns, though, letting us use this feature for free.
 *
 * This has to be done before `plugins_loaded`.
 * @link https://docs.wpvip.com/technical-references/elasticsearch/integrating-jetpack-search/.
 */

define( 'JETPACK_SEARCH_VIP_INDEX', true );

add_filter( 'pre_option_has_jetpack_search_product', '__return_true' );
add_filter( 'jetpack_active_modules', __NAMESPACE__ . '\enable_jetpack_search_module', 9999 );

function enable_jetpack_search_module( $modules ) {
	if ( ! in_array( 'search', $modules, true ) ) {
		$modules[] = 'search';
	}

	return $modules;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Pattern Directory API The pattern API on WordPress.org, and/or the CPT endpoint [Component] Pattern Directory The backend of the pattern directory: submission, management, etc [Type] Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search description instead of post content
2 participants