Skip to content

Commit

Permalink
Merge pull request #122 from alleyinteractive/release-0.4
Browse files Browse the repository at this point in the history
0.4 Release
  • Loading branch information
mboynes authored Apr 16, 2020
2 parents 4aa9387 + 4e3bda5 commit 1b3b5ae
Show file tree
Hide file tree
Showing 35 changed files with 1,889 additions and 909 deletions.
91 changes: 67 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,98 @@
sudo: false
dist: trusty
# Travis CI (MIT License) configuration file for SearchPress
# @link https://travis-ci.org/

language: php
# Xenial does not start mysql by default
services:
- mysql

notifications:
email:
on_success: never
on_failure: change
# Declare project language.
# @link http://about.travis-ci.org/docs/user/languages/php/
language: php

# Specify when Travis should build.
branches:
only:
- master
- /^release-.*$/

cache:
directories:
- $HOME/.composer/cache
- $HOME/.config/composer/cache

# Git clone depth.
git:
depth: 1

matrix:
include:
- php: 5.4
env: WP_VERSION=4.9.10 PHP_LINT=1 ES_VERSION=1.3.0
- php: 5.6
env: WP_VERSION=latest PHP_LINT=1 ES_VERSION=1.7.6
env: WP_VERSION=4.9.10 PHP_LINT=1 ES_VERSION=1.7.6
dist: trusty
- php: 7.0
env: WP_VERSION=nightly WP_PHPCS=1 ES_VERSION=5.6.0
- php: 7.1
env: WP_VERSION=latest PHP_LINT=1 ES_VERSION=2.4.6
dist: trusty
- php: 7.1
env: WP_VERSION=latest PHP_LINT=1 ES_VERSION=5.6.16
dist: xenial
- php: 7.2
env: WP_VERSION=nightly PHP_LINT=1 ES_VERSION=6.4.1
env: WP_VERSION=latest PHP_LINT=1 ES_VERSION=6.8.8
dist: xenial
- php: 7.3
env: WP_VERSION=nightly PHP_LINT=1 WP_PHPCS=1 ES_VERSION=7.6.2
dist: xenial

install:
- bash bin/install-es.sh $ES_VERSION

# Prepare your build for testing.
# Failures in this section will result in build status 'errored'.
before_script:
- export PATH="$HOME/.config/composer/vendor/bin:$HOME/.composer/vendor/bin:$PATH"
- |
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
phpenv config-rm xdebug.ini
else
echo "xdebug.ini does not exist"
fi

# Turn off Xdebug. See https://core.trac.wordpress.org/changeset/40138.
- phpenv config-rm xdebug.ini || echo "Xdebug not available"

- |
if [[ ! -z "$WP_VERSION" ]] ; then
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
composer global require "phpunit/phpunit=4.8.*|5.7.*"
fi
# Couple the PHPUnit version to the PHP version.
- |
case "$TRAVIS_PHP_VERSION" in
5.6)
echo "Using PHPUnit 4.8"
composer global require "phpunit/phpunit=4.8.*"
;;
*)
echo "Using PHPUnit 6.1"
composer global require "phpunit/phpunit=6.1.*"
;;
esac
- |
if [[ "$WP_PHPCS" == "1" ]]; then
composer global require automattic/vipwpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs
fi
- sleep 5
- curl localhost:9200 && echo "ES is up" || (cat /tmp/elasticsearch.log && exit 1)
- phpunit --version
- which phpunit
# Wait up to 60 seconds until ES is up, or die if it never comes up.
- |
failures=0
curl localhost:9200;
while [[ $? -ne 0 && $failures -lt 60 ]]; do
sleep 1
((failures++))
curl localhost:9200
done
if [ $? -ne 0 ]; then
echo "Elasticsearch is unavailable."
cat /tmp/elasticsearch.log
exit 1
fi
script:
- if [[ "$PHP_LINT" == "1" ]]; then find . -type "f" -iname "*.php" | xargs -L "1" php -l; fi
Expand All @@ -64,3 +102,8 @@ script:

after_script:
- cat /tmp/elasticsearch.log

# Receive notifications for build results.
# @link http://docs.travis-ci.com/user/notifications/#Email-notifications
notifications:
email: false
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Each stable release will be tagged and you'll be able to [download that release
Prerequisites
-------------

* [elasticsearch](https://www.elastic.co/products/elasticsearch) 1.3+; 5.0 recommended.
* [elasticsearch](https://www.elastic.co/products/elasticsearch) 1.7+; 5.0+ recommended.
* PHP 5.3+; PHP 7 recommended.


Expand All @@ -29,9 +29,72 @@ Setup
4. Once indexing is complete, you're good to go!


Indexing Post Meta
------------------

In early versions of SearchPress, SearchPress would index almost all post meta with the post. Starting in the 0.4 release, SearchPress only indexes the post meta that it is explicitly told to index. Further, it only indexes post meta in the _data types_ that a site's developer plans to use. The principal reason behind this change is performance, and to prevent ["mappings explosion"](https://www.elastic.co/guide/en/elasticsearch/reference/master/mapping.html#mapping-limit-settings).

Data type casting will only be attempted for a key if the opt-in callback specifies that type for the key in question (see example below for the full list of possible types). However, the data type will still only be indexed if the type casting is successful. For example, attempting to index the meta value `"WordPress"` as a `long` would fail, since it is not a numeric value. This failure is silent, for better or worse, but type casting is overall quite forgiving.

If a meta key is allowed to be indexed, the meta value will _always_ be indexed as an unanalyzed string (`post_meta.*.raw`) and that type need not be specified. This is primarily for compatibility with [ES_WP_Query](https://github.com/alleyinteractive/es-wp-query), which depends on that key in `EXISTS` queries, among others.

### How to index post meta

```php
add_filter(
'sp_post_allowed_meta',
function( $allowed_meta ) {
// Tell SearchPress to index 'some_meta_key' post meta when encountered.
$allowed_meta['some_meta_key'] = [
'value', // Index as an analyzed string.
'boolean', // Index as a boolean value.
'long', // Index as a "long" (integer).
'double', // Index as a "double" (floating point number).
'date', // Index as a GMT date-only value in the format Y-m-d.
'datetime', // Index as a GMT datetime value in the format Y-m-d H:i:s.
'time', // Index as a GMT time-only value in the format H:i:s.
];
return $allowed_meta;
}
);
```

Changelog
---------

### 0.4

* **CRITICAL BREAKING CHANGE:** Post meta indexing is now opt-in. See README for more information.
* Adds support for ES 5.x, 6.x, 7.x
* Fixes indexing bug with parentless attachments
* Fixes a bug with bulk syncing attachments
* Improves flexibility for custom indexing of posts
* Improves facet lists to exclude current selections
* Adds option in the admin to index content without flushing
* Fixes bug with cached list of post types to sync
* Fixes conflicts with Advanced Post Cache and CLI-based cron runners
* Adds completion suggester API for search-as-you-type functionality
* Fixes bug with SSL cert verification
* Overhaul of phpunit testing environment for performance
* General coding standards cleanup


### 0.3

* Adds heartbeat to monitor Elasticsearch
* Improves capabilities handling for admin settings
* Adds a status tab to admin page
* Improves test coverage for heartbeat and admin settings
* Fixes bug with post type facet field
* Allows multiple post IDs to be passed to cli index command
* Locally cache API host to improve external referencing to it
* Fixes edge case bugs with indexing, e.g. with long meta strings
* Improves indexed/searched post types and statuses handling
* Tests across a wider range of ES versions using CI
* Stores/checks mapping version
* General code improvements


### 0.2

* Adds unit testing
Expand Down
6 changes: 3 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: mboynes, alleyinteractive
Tags: search, elasticsearch, faceted search, performance
Requires at least: 4.8.0
Tested up to: 5.2
Stable tag: 0.3
Tested up to: 5.4
Stable tag: 0.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -17,7 +17,7 @@ server.

== Prerequisites ==

* PHP 5.3+
* PHP 5.6+
* Elasticsearch

== Installation ==
Expand Down
6 changes: 6 additions & 0 deletions assets/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
width: 500px;
max-width: 100%;
}
.tools_page_searchpress span.explanation {
display:block;
font-size: 90%;
padding-left: 24px;
font-style: italic;
}
#searchpress-stats {
margin: 20px 0;
}
Expand Down
12 changes: 6 additions & 6 deletions bin/install-es.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ if [ $# -lt 1 ]; then
fi

ES_VERSION=$1
echo $JAVA_HOME

setup_es() {
download_url=$1
Expand All @@ -24,13 +23,14 @@ if [[ "$ES_VERSION" == 1.* ]]; then
setup_es https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
elif [[ "$ES_VERSION" == 2.* ]]; then
setup_es https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz
else
elif [[ "$ES_VERSION" == [56].* ]]; then
setup_es https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
else
setup_es https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
fi

# java_home='/usr/lib/jvm/java-8-oracle'
if [[ "$ES_VERSION" == [56].* ]]; then
start_es '-Epath.repo=/tmp -Enetwork.host=_local_'
else
if [[ "$ES_VERSION" == [12].* ]]; then
start_es '-Des.path.repo=/tmp'
else
start_es '-Epath.repo=/tmp -Enetwork.host=_local_'
fi
Loading

0 comments on commit 1b3b5ae

Please sign in to comment.