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

Filtering REST API queries while requesting with a slug parameter #1519

Closed
jayhill90 opened this issue Oct 10, 2019 · 4 comments
Closed

Filtering REST API queries while requesting with a slug parameter #1519

jayhill90 opened this issue Oct 10, 2019 · 4 comments
Assignees
Milestone

Comments

@jayhill90
Copy link

jayhill90 commented Oct 10, 2019

Describe the bug
When filtering REST API post type queries with $args['ep_integrate'] = true; for a post type, you can no longer make a request with slug=post-name as a query parameter. You get back the 10 most recent posts of that post type.

Unfortunately, since this is only observed while querying the REST API, I haven't found a way to be able to inspect the queries being generated in EP or what that looks like on the ES side of things.

Steps to Reproduce
Filter a specific post type query, rest_post_query or rest_CUSTOMPOSTTYPE_query and prior to returning $args set $args['ep_integrate'] = true.
Make a request to /wp-json/wp/v2/POSTTYPE?slug=APOSTSLUG You'll get back the latest 10 posts of that post type.
Remove $args['ep_integrate'] = true and make the same request. You should get back the specific requested data.

Expected behavior
The only post(s) we should receive back when passing in ?slug= to the REST API are the specific posts that correspond to the passed in post_name__in array.

Environment information

  • Device: MacBook Pro
  • OS: OS X, Linux, Doesn't matter
  • Browser and version: Postman
  • Plugins and version: ElasticPress 3.1.4
  • Theme and version: Custom Build
  • Other installed plugin(s) and version(s): N/A

Additional context

I tested this with a few different rest_POSTTYPE_query filters for different post types and it only works when I remove the code to integrate the query into ElasticPress.

Maybe this isn't an actual bug on the EP side and I'm just lost in a rabbit hole and this is all for naught.

The other thought i had was that maybe ElasticSearch just doesn't know what to do with the post_name__in argument and how to map that as there's no slug value in ES when querying through Kibana, but there is post_name. Is it maybe possible that maybe EPdoesn't have a way to associate post_name__in to post_name in ES?

Thanks!

@jayhill90 jayhill90 added the type:bug Something isn't working. label Oct 10, 2019
@tlovett1
Copy link
Member

Currently EP doesn't support post_name__in which is used when passing slug. We can probably add this to the next version.

@tlovett1 tlovett1 added enhancement and removed type:bug Something isn't working. labels Oct 14, 2019
@tlovett1
Copy link
Member

For the time being just don't ep_integrate if post_name__in is used.

@jayhill90
Copy link
Author

Thanks Taylor.

@oscarssanchez
Copy link
Contributor

Estimating 2 hours for this.

@mckdemps mckdemps added small (< 4 hours) and removed needs estimate labels Apr 23, 2021
@mckdemps mckdemps added this to the 3.6.0 milestone Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants