function test_faceting() { $s = new SP_WP_Search(array('post_type' => array('post', 'page'), 'posts_per_page' => 0, 'facets' => array('Tag' => array('type' => 'taxonomy', 'taxonomy' => 'post_tag', 'count' => 10), 'Post Type' => array('type' => 'post_type', 'count' => 10), 'Histogram' => array('type' => 'date_histogram', 'interval' => 'year', 'count' => 10)))); $facets = $s->get_results('facets'); $this->assertNotEmpty($facets); $this->assertNotEmpty($facets['Tag']['buckets']); $this->assertNotEmpty($facets['Post Type']['buckets']); $this->assertNotEmpty($facets['Histogram']['buckets']); }
/** * Run a search through SearchPress using WP-friendly syntax. * * @see SP_WP_Search * * @param array $wp_args PHP array of search arguments. * @return array Search results. */ function sp_wp_search($wp_args, $raw_result = false) { $s = new SP_WP_Search($wp_args); return $raw_result ? $s->get_results() : $s->get_posts(); }