Skip to content

Commit

Permalink
Rename filters to queries.
Browse files Browse the repository at this point in the history
Filters no longer exist in 2.0. Only queries exist in the DSL.
  • Loading branch information
dieterve committed Nov 6, 2015
1 parent df8a4ae commit 2b08883
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 53 deletions.
8 changes: 4 additions & 4 deletions docs/re-useable-fragments.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for easy manipulation.

```php
use ElasticSearcher\Abstracts\AbstractQuery;
use ElasticSearcher\Fragments\Filters\TermFilter;
use ElasticSearcher\Fragments\Queries\TermQuery;

class MoviesYouMightLikeQuery extends AbstractQuery
{
Expand All @@ -24,7 +24,7 @@ class MoviesYouMightLikeQuery extends AbstractQuery
'query' => array(
'bool' => array(
'filter' => array(
new TermFilter('status', 'active')
new TermQuery('status', 'active')
)
)
)
Expand Down Expand Up @@ -72,8 +72,8 @@ root. You can do this by setting the `mergeWithParent` property on a fragment to
```php
$body = [
'and' => [
new TermFilter('status', 'active'),
new TermFilter('published', true),
new TermQuery('status', 'active'),
new TermQuery('published', true),
]
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace ElasticSearcher\Fragments\Filters;
namespace ElasticSearcher\Fragments\Queries;

use ElasticSearcher\Abstracts\AbstractFragment;

/**
* Simple term filter.
* Simple term query.
*
* @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
* @package ElasticSearcher\Fragments\Filters
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
* @package ElasticSearcher\Fragments\Queries
*/
class TermFilter extends AbstractFragment
class TermQuery extends AbstractFragment
{
/**
* @param string $field
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace ElasticSearcher\Fragments\Filters;
namespace ElasticSearcher\Fragments\Queries;

use ElasticSearcher\Abstracts\AbstractFragment;

/**
* Simple terms filter.
* Simple terms query.
*
* @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
* @package ElasticSearcher\Fragments\Filters
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
* @package ElasticSearcher\Fragments\Queries
*/
class TermsFilter extends AbstractFragment
class TermsQuery extends AbstractFragment
{
/**
* @param string $field
Expand Down
13 changes: 0 additions & 13 deletions tests/Fragments/Filters/TermFilterTest.php

This file was deleted.

13 changes: 0 additions & 13 deletions tests/Fragments/Filters/TermsFilterTest.php

This file was deleted.

13 changes: 13 additions & 0 deletions tests/Fragments/Queries/TermQueryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use ElasticSearcher\Fragments\Queries\TermQuery;

class TermQueryTest extends PHPUnit_Framework_TestCase
{
public function testBody()
{
$term = new TermQuery('name', 'elasticsearch');

$this->assertEquals(['term' => ['name' => 'elasticsearch']], $term->getBody());
}
}
13 changes: 13 additions & 0 deletions tests/Fragments/Queries/TermsQueryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use ElasticSearcher\Fragments\Queries\TermsQuery;

class TermsQueryTest extends PHPUnit_Framework_TestCase
{
public function testBody()
{
$term = new TermsQuery('name', ['elasticsearch', 'github']);

$this->assertEquals(['terms' => ['name' => ['elasticsearch', 'github']]], $term->getBody());
}
}
10 changes: 5 additions & 5 deletions tests/Parsers/FragmentParserTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use ElasticSearcher\Parsers\FragmentParser;
use ElasticSearcher\Fragments\Filters\TermFilter;
use ElasticSearcher\Fragments\Queries\TermQuery;
use ElasticSearcher\Fragments\Analyzers\StandardAnalyzer;

class FragmentParserTest extends ElasticSearcherTestCase
Expand All @@ -11,7 +11,7 @@ public function testParsingRootLevel()
$parser = new FragmentParser();

$body = [
'query' => new TermFilter('name', 'John'),
'query' => new TermQuery('name', 'John'),
];
$expectedBody = [
'query' => [
Expand All @@ -32,8 +32,8 @@ public function testParsingChildLevel()
'query' => [
'bool' => [
'and' => [
new TermFilter('name', 'John'),
new TermFilter('category', 'authors'),
new TermQuery('name', 'John'),
new TermQuery('category', 'authors'),
]
]
]
Expand Down Expand Up @@ -68,7 +68,7 @@ public function testParsingNestedFragments()
'query' => [
'bool' => [
'and' => [
new TermFilter('name', new TermFilter('category', 'authors')),
new TermQuery('name', new TermQuery('category', 'authors')),
]
]
]
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/Fragments/Filters/IDFilter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use ElasticSearcher\Abstracts\AbstractFragment;
use ElasticSearcher\Fragments\Filters\TermFilter;
use ElasticSearcher\Fragments\Queries\TermQuery;

class IDFilter extends AbstractFragment
{
Expand All @@ -20,6 +20,6 @@ public function __construct($id)

public function getBody()
{
return new TermFilter('id', $this->id);
return new TermQuery('id', $this->id);
}
}
4 changes: 2 additions & 2 deletions tests/dummy/Queries/CountMoviesFrom2014Query.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

use ElasticSearcher\Abstracts\AbstractQuery;
use ElasticSearcher\Fragments\Filters\TermFilter;
use ElasticSearcher\Fragments\Queries\TermQuery;

class CountMoviesFrom2014Query extends AbstractQuery
{
public function setup()
{
$this->searchIn('movies', 'movies');

$this->set('query.bool.filter', [new TermFilter('year', 2014)]);
$this->set('query.bool.filter', [new TermQuery('year', 2014)]);

$this->setSearchType('count');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/Queries/MoviesFrom2014Query.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

use ElasticSearcher\Abstracts\AbstractQuery;
use ElasticSearcher\Fragments\Filters\TermFilter;
use ElasticSearcher\Fragments\Queries\TermQuery;

class MoviesFrom2014Query extends AbstractQuery
{
public function setup()
{
$this->searchIn('movies', 'movies');

$this->set('query.bool.filter', [new TermFilter('year', 2014)]);
$this->set('query.bool.filter', [new TermQuery('year', 2014)]);
}
}
4 changes: 2 additions & 2 deletions tests/dummy/Queries/MoviesFromXYearQuery.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use ElasticSearcher\Abstracts\AbstractQuery;
use ElasticSearcher\Fragments\Filters\TermFilter;
use ElasticSearcher\Fragments\Queries\TermQuery;

class MoviesFromXYearQuery extends AbstractQuery
{
Expand All @@ -26,7 +26,7 @@ public function parseYear()
{
$year = $this->getData('year');
if ($year) {
return new TermFilter('year', $year);
return new TermQuery('year', $year);
}
}
}

0 comments on commit 2b08883

Please sign in to comment.