Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: php

php:
- 5.4
- 5.5
- 5.6
# - hhvm # currently failing with: Message was: "DateTimeZone::__construct(): Unknown or bad timezone (+00:00)"
- 7.1
- 7.2

before_script:
- composer self-update
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG-0.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
This changelog references the relevant changes done in 0.x versions.


## v0.3.0
__BREAKING CHANGES__

* Update `ElasticaQueryBuilder` to use `"ruflin/elastica": "~5.3"`.
* Require php `>=7.1` in `composer.json`.
* Add php7 type hinting and use `declare(strict_types=1);`.


## v0.2.1
* pull #9: Respect boolean operator preceding subquery.


## v0.2.0
__BREAKING CHANGES__

* issue #7: Update ElasticaQueryBuilder to use 2.x queries/filters. Requires `"ruflin/elastica": "~3.2"`.
* issue #7: Update `ElasticaQueryBuilder` to use 2.x queries/filters. Requires `"ruflin/elastica": "~3.2"`.
* issue #6: Make TimeZone configurable on any builders that use date nodes.
* The `Number` class was renamed to `Numbr` to prevent issue with scalar type hints in php7.

Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"type": "library",
"license": "Apache-2.0",
"require": {
"php": ">=5.4",
"php": ">=7.1",
"gdbots/common": "~0.1|~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.3",
"ruflin/elastica": "~3.2"
"phpunit/phpunit": "~6.4",
"ruflin/elastica": "~5.3"
},
"autoload": {
"psr-4": {
Expand All @@ -22,9 +22,12 @@
"Gdbots\\Tests\\QueryParser\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "0.2.x-dev"
"dev-master": "0.3.x-dev"
}
}
}
18 changes: 14 additions & 4 deletions examples/elastica.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ class EchoLogger implements \Psr\Log\LoggerInterface
* @param mixed $level
* @param string $message
* @param array $context
*
* @return null
*/
public function log($level, $message, array $context = array())
{
echo $message.PHP_EOL;

// nuke hits from context since we print those
// after response data anyways
if (isset($context['response']) && isset($context['response']['hits']) && isset($context['response']['hits']['hits'])) {
unset($context['response']['hits']['hits']);
}

echo json_encode($context, JSON_PRETTY_PRINT).PHP_EOL.PHP_EOL;
echo str_repeat(PHP_EOL, 2).str_repeat('*', 70).str_repeat(PHP_EOL, 2);
}
Expand All @@ -34,11 +39,16 @@ public function log($level, $message, array $context = array())
$client->setLogger(new EchoLogger());

$parser = new QueryParser();
/** @var ElasticaQueryBuilder $builder */
$builder = (new ElasticaQueryBuilder())
->addNestedField('dynamic_fields')
->setDefaultFieldName('_all')
->setEmoticonFieldName('emoticons')
->setHashtagFieldName('hashtags')
->setMentionFieldName('mentions')
->addFullTextSearchField('subject')
->addFullTextSearchField('dynamic_fields.string_val')
->addFullTextSearchField('dynamic_fields.text_val')
->setLocalTimeZone(new DateTimeZone('America/Los_Angeles'))
;

Expand All @@ -58,13 +68,13 @@ public function log($level, $message, array $context = array())
->setQuery($query)
->setBoostMode(FunctionScore::BOOST_MODE_SUM)
->addFunction('field_value_factor', [
'field' => '__popularity',
'field' => 'priority',
'modifier' => 'none',
], null, 0.4);
*/
$query = \Elastica\Query::create($query);
//$query->setExplain(true);
//$query->setSort(['published_at' => 'desc']);
$query->setSort(['date_sent' => 'desc']);
$results = $client->getIndex($index)->search($query, $options);

echo 'Total Time (ms) / Records Found:' . PHP_EOL;
Expand Down
Loading