diff --git a/docs/re-useable-fragments.md b/docs/re-useable-fragments.md index 8a506f0..7f2e4f5 100644 --- a/docs/re-useable-fragments.md +++ b/docs/re-useable-fragments.md @@ -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 { @@ -24,7 +24,7 @@ class MoviesYouMightLikeQuery extends AbstractQuery 'query' => array( 'bool' => array( 'filter' => array( - new TermFilter('status', 'active') + new TermQuery('status', 'active') ) ) ) @@ -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), ] ]; diff --git a/src/Fragments/Filters/TermFilter.php b/src/Fragments/Queries/TermQuery.php similarity index 50% rename from src/Fragments/Filters/TermFilter.php rename to src/Fragments/Queries/TermQuery.php index 303a459..629df55 100644 --- a/src/Fragments/Filters/TermFilter.php +++ b/src/Fragments/Queries/TermQuery.php @@ -1,16 +1,16 @@ assertEquals(['term' => ['name' => 'elasticsearch']], $term->getBody()); - } -} diff --git a/tests/Fragments/Filters/TermsFilterTest.php b/tests/Fragments/Filters/TermsFilterTest.php deleted file mode 100644 index ee559aa..0000000 --- a/tests/Fragments/Filters/TermsFilterTest.php +++ /dev/null @@ -1,13 +0,0 @@ -assertEquals(['terms' => ['name' => ['elasticsearch', 'github']]], $term->getBody()); - } -} diff --git a/tests/Fragments/Queries/TermQueryTest.php b/tests/Fragments/Queries/TermQueryTest.php new file mode 100644 index 0000000..9f30557 --- /dev/null +++ b/tests/Fragments/Queries/TermQueryTest.php @@ -0,0 +1,13 @@ +assertEquals(['term' => ['name' => 'elasticsearch']], $term->getBody()); + } +} diff --git a/tests/Fragments/Queries/TermsQueryTest.php b/tests/Fragments/Queries/TermsQueryTest.php new file mode 100644 index 0000000..4463b5b --- /dev/null +++ b/tests/Fragments/Queries/TermsQueryTest.php @@ -0,0 +1,13 @@ +assertEquals(['terms' => ['name' => ['elasticsearch', 'github']]], $term->getBody()); + } +} diff --git a/tests/Parsers/FragmentParserTest.php b/tests/Parsers/FragmentParserTest.php index 59664c9..76903de 100644 --- a/tests/Parsers/FragmentParserTest.php +++ b/tests/Parsers/FragmentParserTest.php @@ -1,7 +1,7 @@ new TermFilter('name', 'John'), + 'query' => new TermQuery('name', 'John'), ]; $expectedBody = [ 'query' => [ @@ -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'), ] ] ] @@ -68,7 +68,7 @@ public function testParsingNestedFragments() 'query' => [ 'bool' => [ 'and' => [ - new TermFilter('name', new TermFilter('category', 'authors')), + new TermQuery('name', new TermQuery('category', 'authors')), ] ] ] diff --git a/tests/dummy/Fragments/Filters/IDFilter.php b/tests/dummy/Fragments/Filters/IDFilter.php index 85d98e8..bccd7cd 100644 --- a/tests/dummy/Fragments/Filters/IDFilter.php +++ b/tests/dummy/Fragments/Filters/IDFilter.php @@ -1,7 +1,7 @@ id); + return new TermQuery('id', $this->id); } } diff --git a/tests/dummy/Queries/CountMoviesFrom2014Query.php b/tests/dummy/Queries/CountMoviesFrom2014Query.php index bc3db4a..e2988d9 100644 --- a/tests/dummy/Queries/CountMoviesFrom2014Query.php +++ b/tests/dummy/Queries/CountMoviesFrom2014Query.php @@ -1,7 +1,7 @@ searchIn('movies', 'movies'); - $this->set('query.bool.filter', [new TermFilter('year', 2014)]); + $this->set('query.bool.filter', [new TermQuery('year', 2014)]); $this->setSearchType('count'); } diff --git a/tests/dummy/Queries/MoviesFrom2014Query.php b/tests/dummy/Queries/MoviesFrom2014Query.php index e8ed2ab..cd85ac7 100644 --- a/tests/dummy/Queries/MoviesFrom2014Query.php +++ b/tests/dummy/Queries/MoviesFrom2014Query.php @@ -1,7 +1,7 @@ searchIn('movies', 'movies'); - $this->set('query.bool.filter', [new TermFilter('year', 2014)]); + $this->set('query.bool.filter', [new TermQuery('year', 2014)]); } } diff --git a/tests/dummy/Queries/MoviesFromXYearQuery.php b/tests/dummy/Queries/MoviesFromXYearQuery.php index 5178ff5..5366fc3 100644 --- a/tests/dummy/Queries/MoviesFromXYearQuery.php +++ b/tests/dummy/Queries/MoviesFromXYearQuery.php @@ -1,7 +1,7 @@ getData('year'); if ($year) { - return new TermFilter('year', $year); + return new TermQuery('year', $year); } } }