{"action":"created","issue":{"url":"https://api.github.com/repos/10up/ElasticPress/issues/491","repository_url":"https://api.github.com/repos/10up/ElasticPress","labels_url":"https://api.github.com/repos/10up/ElasticPress/issues/491/labels{/name}","comments_url":"https://api.github.com/repos/10up/ElasticPress/issues/491/comments","events_url":"https://api.github.com/repos/10up/ElasticPress/issues/491/events","html_url":"https://github.com/10up/ElasticPress/issues/491","id":148821460,"number":491,"title":"Add support for WP REST API","user":{"login":"jakejackson1","id":2918419,"avatar_url":"https://avatars.githubusercontent.com/u/2918419?v=3","gravatar_id":"","url":"https://api.github.com/users/jakejackson1","html_url":"https://github.com/jakejackson1","followers_url":"https://api.github.com/users/jakejackson1/followers","following_url":"https://api.github.com/users/jakejackson1/following{/other_user}","gists_url":"https://api.github.com/users/jakejackson1/gists{/gist_id}","starred_url":"https://api.github.com/users/jakejackson1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakejackson1/subscriptions","organizations_url":"https://api.github.com/users/jakejackson1/orgs","repos_url":"https://api.github.com/users/jakejackson1/repos","events_url":"https://api.github.com/users/jakejackson1/events{/privacy}","received_events_url":"https://api.github.com/users/jakejackson1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-16T06:04:54Z","updated_at":"2016-04-26T07:12:11Z","closed_at":null,"body":"It would be great if ElasticPress support could be also applied to doing searches via the WP REST API. "},"comment":{"url":"https://api.github.com/repos/10up/ElasticPress/issues/comments/214644365","html_url":"https://github.com/10up/ElasticPress/issues/491#issuecomment-214644365","issue_url":"https://api.github.com/repos/10up/ElasticPress/issues/491","id":214644365,"user":{"login":"jakejackson1","id":2918419,"avatar_url":"https://avatars.githubusercontent.com/u/2918419?v=3","gravatar_id":"","url":"https://api.github.com/users/jakejackson1","html_url":"https://github.com/jakejackson1","followers_url":"https://api.github.com/users/jakejackson1/followers","following_url":"https://api.github.com/users/jakejackson1/following{/other_user}","gists_url":"https://api.github.com/users/jakejackson1/gists{/gist_id}","starred_url":"https://api.github.com/users/jakejackson1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakejackson1/subscriptions","organizations_url":"https://api.github.com/users/jakejackson1/orgs","repos_url":"https://api.github.com/users/jakejackson1/repos","events_url":"https://api.github.com/users/jakejackson1/events{/privacy}","received_events_url":"https://api.github.com/users/jakejackson1/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T07:12:11Z","updated_at":"2016-04-26T07:12:11Z","body":"I just ensured that particular custom post type is included in the index. \r\n\r\nI also used xdebug to sniff out what's different in the query variable array between the standard and REST API searches. \r\n\r\nHere's the dump of the standard search:\r\n\r\n```\r\nArray\r\n(\r\n    [s] => shortcode\r\n    [post_type] => v4_docs\r\n    [error] => \r\n    [m] => \r\n    [p] => 0\r\n    [post_parent] => \r\n    [subpost] => \r\n    [subpost_id] => \r\n    [attachment] => \r\n    [attachment_id] => 0\r\n    [name] => \r\n    [static] => \r\n    [pagename] => \r\n    [page_id] => 0\r\n    [second] => \r\n    [minute] => \r\n    [hour] => \r\n    [day] => 0\r\n    [monthnum] => 0\r\n    [year] => 0\r\n    [w] => 0\r\n    [category_name] => \r\n    [tag] => \r\n    [cat] => \r\n    [tag_id] => \r\n    [author] => \r\n    [author_name] => \r\n    [feed] => \r\n    [tb] => \r\n    [paged] => 0\r\n    [meta_key] => \r\n    [meta_value] => \r\n    [preview] => \r\n    [sentence] => \r\n    [title] => \r\n    [fields] => \r\n    [menu_order] => \r\n    [embed] => \r\n    [category__in] => Array\r\n        (\r\n        )\r\n\r\n    [category__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [category__and] => Array\r\n        (\r\n        )\r\n\r\n    [post__in] => Array\r\n        (\r\n        )\r\n\r\n    [post__not_in] => Array\r\n        (\r\n            [0] => 7152\r\n            [1] => 5642\r\n        )\r\n\r\n    [post_name__in] => Array\r\n        (\r\n        )\r\n\r\n    [tag__in] => Array\r\n        (\r\n        )\r\n\r\n    [tag__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [tag__and] => Array\r\n        (\r\n        )\r\n\r\n    [tag_slug__in] => Array\r\n        (\r\n        )\r\n\r\n    [tag_slug__and] => Array\r\n        (\r\n        )\r\n\r\n    [post_parent__in] => Array\r\n        (\r\n        )\r\n\r\n    [post_parent__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [author__in] => Array\r\n        (\r\n        )\r\n\r\n    [author__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [cache_results] => \r\n    [ignore_sticky_posts] => \r\n    [suppress_filters] => \r\n    [update_post_term_cache] => 1\r\n    [update_post_meta_cache] => 1\r\n    [posts_per_page] => 10\r\n    [nopaging] => \r\n    [comments_per_page] => 50\r\n    [no_found_rows] => \r\n    [search_terms_count] => 1\r\n    [search_terms] => Array\r\n        (\r\n            [0] => shortcode\r\n        )\r\n\r\n    [search_orderby_title] => Array\r\n        (\r\n            [0] => wp_posts.post_title LIKE '%shortcode%'\r\n        )\r\n\r\n    [order] => DESC\r\n)\r\n```\r\n\r\nAnd here's the same dump when doing the REST API search:\r\n\r\n```\r\nArray\r\n(\r\n    [s] => shortcode\r\n    [paged] => 1\r\n    [order] => DESC\r\n    [orderby] => date\r\n    [post_type] => v4_docs\r\n    [author__in] => Array\r\n        (\r\n        )\r\n\r\n    [author__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [post__in] => Array\r\n        (\r\n        )\r\n\r\n    [post__not_in] => Array\r\n        (\r\n            [0] => 7152\r\n            [1] => 5642\r\n        )\r\n\r\n    [posts_per_page] => 10\r\n    [date_query] => Array\r\n        (\r\n        )\r\n\r\n    [ignore_sticky_posts] => 1\r\n    [error] => \r\n    [m] => \r\n    [p] => 0\r\n    [post_parent] => \r\n    [subpost] => \r\n    [subpost_id] => \r\n    [attachment] => \r\n    [attachment_id] => 0\r\n    [name] => \r\n    [static] => \r\n    [pagename] => \r\n    [page_id] => 0\r\n    [second] => \r\n    [minute] => \r\n    [hour] => \r\n    [day] => 0\r\n    [monthnum] => 0\r\n    [year] => 0\r\n    [w] => 0\r\n    [category_name] => \r\n    [tag] => \r\n    [cat] => \r\n    [tag_id] => \r\n    [author] => \r\n    [author_name] => \r\n    [feed] => \r\n    [tb] => \r\n    [meta_key] => \r\n    [meta_value] => \r\n    [preview] => \r\n    [sentence] => \r\n    [title] => \r\n    [fields] => \r\n    [menu_order] => \r\n    [embed] => \r\n    [category__in] => Array\r\n        (\r\n        )\r\n\r\n    [category__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [category__and] => Array\r\n        (\r\n        )\r\n\r\n    [post_name__in] => Array\r\n        (\r\n        )\r\n\r\n    [tag__in] => Array\r\n        (\r\n        )\r\n\r\n    [tag__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [tag__and] => Array\r\n        (\r\n        )\r\n\r\n    [tag_slug__in] => Array\r\n        (\r\n        )\r\n\r\n    [tag_slug__and] => Array\r\n        (\r\n        )\r\n\r\n    [post_parent__in] => Array\r\n        (\r\n        )\r\n\r\n    [post_parent__not_in] => Array\r\n        (\r\n        )\r\n\r\n    [cache_results] => \r\n    [suppress_filters] => \r\n    [update_post_term_cache] => 1\r\n    [update_post_meta_cache] => 1\r\n    [nopaging] => \r\n    [comments_per_page] => 50\r\n    [no_found_rows] => \r\n    [search_terms_count] => 1\r\n    [search_terms] => Array\r\n        (\r\n            [0] => shortcode\r\n        )\r\n\r\n    [search_orderby_title] => Array\r\n        (\r\n            [0] => wp_posts.post_title LIKE '%shortcode%'\r\n        )\r\n\r\n)\r\n```\r\n\r\nThe two interesting differences that stood out where the `paged` and `orderby` keys. I forced `paged` to be `0` which had no effect, but when I unset `orderby` the search results were exactly the same. \r\n\r\nNow, the search on the REST API uses the standard endpoint structure `/wp-json/wp/v2/v4_docs/?search=shortcodes` which means it's defaulting to the ordering by date, while the standard search doesn't appear to include an orderby. That suggests there's a bug in the REST API – unless ElasticPress manipulates the orderby at some stage... \r\n\r\n"}}