Skip to content

Commit

Permalink
Merge branch 'point-release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tlovett1 committed Apr 9, 2015
2 parents 060b9f5 + cdfe1b4 commit 3f88579
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: php

php:
- "5.5"
- "5.2"
- "5.3"

env:
- WP_VERSION=latest WP_MULTISITE=0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ After running an index, ElasticPress integrates with `WP_Query` if and only if t

* ```orderby``` (*string*)

Order results by field name instead of relevance. Currently only supports: ```title```, ```name```, and ```relevance``` (default).
Order results by field name instead of relevance. Currently only supports: ```title```, ```name```, ```date```, and ```relevance``` (default).

* ```order``` (*string*)

Expand Down
11 changes: 11 additions & 0 deletions classes/class-ep-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ protected function parse_order( $order ) {
* @access protected
*
* @param string $orderby Alias for the field to order by.
* @param string $order
* @return array|bool Array formatted value to used in the sort DSL. False otherwise.
*/
protected function parse_orderby( $orderby, $order ) {
Expand All @@ -1165,6 +1166,7 @@ protected function parse_orderby( $orderby, $order ) {
'relevance',
'name',
'title',
'date',
);

if ( ! in_array( $orderby, $allowed_keys ) ) {
Expand All @@ -1182,6 +1184,15 @@ protected function parse_orderby( $orderby, $order ) {
),
);
break;
case 'date':
$sort = array(
array(
'post_date' => array(
'order' => $order,
),
),
);
break;
case 'name':
case 'title':
$sort = array(
Expand Down
2 changes: 1 addition & 1 deletion elasticpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Plugin Name: ElasticPress
* Description: Integrate WordPress search with Elasticsearch
* Version: 1.3
* Version: 1.3.1
* Author: Aaron Holbrook, Taylor Lovett, Matt Gross, 10up
* Author URI: http://10up.com
* License: GPLv2 or later
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Author URI: http://10up.com
Plugin URI: https://github.com/10up/ElasticPress
Tags: search, elasticsearch, fuzzy, facet, searching, autosuggest, suggest, elastic, advanced search
Requires at least: 3.7.1
Tested up to: 4.1
Stable tag: 1.3
Tested up to: 4.2
Stable tag: 1.3.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -58,6 +58,9 @@ configuring single site and multi-site cross-site search are slightly different.

== Changelog ==

= 1.3.1 =
* Support `date` in WP_Query `orderby`.

= 1.3 =
* Support `meta_query` in WP_Query integration
* Improved documentation. Each WP-CLI command has been documented
Expand Down
31 changes: 31 additions & 0 deletions tests/test-single-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,37 @@ public function testSearchPostTitleOrderbyQuery() {
$this->assertEquals( 'ordertest 111', $query->posts[2]->post_title );
}

/**
* Test post_date orderby query
*
* @since 1.4
*/
public function testSearchPostDateOrderbyQuery() {
ep_create_and_sync_post( array( 'post_title' => 'ordertes 333' ) );
sleep( 3 );

ep_create_and_sync_post( array( 'post_title' => 'ordertest 111' ) );
sleep( 3 );

ep_create_and_sync_post( array( 'post_title' => 'ordertest 222' ) );

ep_refresh_index();

$args = array(
's' => 'ordertest',
'orderby' => 'date',
'order' => 'DESC',
);

$query = new WP_Query( $args );

$this->assertEquals( 3, $query->post_count );
$this->assertEquals( 3, $query->found_posts );
$this->assertEquals( 'ordertes 333', $query->posts[0]->post_title );
$this->assertEquals( 'ordertest 111', $query->posts[1]->post_title );
$this->assertEquals( 'ordertest 222', $query->posts[2]->post_title );
}

/**
* Test relevance orderby query advanced
*
Expand Down

0 comments on commit 3f88579

Please sign in to comment.