Closed ethanclevenger91 closed 3 years ago
@ethanclevenger91 agreed this would be a good thing to get working. Currently, the only way I'm aware of to create a partial match in Elasticsearch is to map this particular field with the ngram analyzer, which enables partial string matches. That could create some indexing overhead, so I'm also wondering if perhaps we could shortcut this by splitting the 'image/
This is admin search correct @ethanclevenger91? I assume you have the Protected Content feature enabled?
Admin - correct. I didn't have the Protected Content feature enabled, though I'm enabling it now after better understanding what it does.
I'm working on it.
I just ran into this - doesn't seem to be fixed in the latest version. The issue is that the plugin assumes if a string value is passed then it's a truncated / prefix mime type and if it's an array then they're fully qualified:
https://github.com/10up/ElasticPress/blob/develop/includes/classes/Indexable/Post/Post.php#L907-L934
This isn't exactly reliable as the image block shows but WP will accept any combination of those truncated and fully qualified values.
I've got a temporary workaround here:
https://github.com/humanmade/altis-enhanced-search/pull/98/files
The latter part of it will nicely handle whatever is passed to the post_mime_type
WP_Query
argument (after converting that value to an array if a string was given:
I'll make a PR as soon as I can.
We can use wp_get_mime_types to check which mime types exist and search for all of them. So, for image/%
it would mean [ 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/tiff', 'image/x-icon', 'image/heic' ]
Describe the bug The Gutenberg image block adds
'post_mime_type' => 'image'
to the media modal's search queries (thequery-attachments
AJAX action). The classic editor didn't add this parameter.ElasticPress translates post_mime_type to an exact match, but in
wp_post_mime_type_where()
, which WP_Query uses to parse that argument, if there's no/
in the post_mime_type, the resulting SQL wildcards the second half of the mime type, soLIKE 'image/%'
(for this specific case).While admin-side functionality isn't the default for this plugin, updating this logic would make it more seamless.
Steps to Reproduce
ep_admin_wp_query_integration
andep_ajax_wp_query_integration
Expected behavior Image search results in the admin should be consistent.
Environment information
Additional context Current workaround is a
pre_get_posts
filter: