@@ -7,17 +7,16 @@ Extension for [ensi/laravel-elastic-query](https://github.com/ensi-platform/lara
771 . Install [ ensi/laravel-elastic-query] ( https://github.com/ensi-platform/laravel-elastic-query/ ) https://github.com/ensi-platform/laravel-elastic-query#installation
882 . ` composer require ensi/laravel-elastic-query-specification `
99
10- ## Usage // TODO translate to english
10+ ## Usage
1111
12- Все виды декларативных запросов строятся на основе спецификации. В ней содержатся определения доступных фильтров, сортировок и
13- агрегатов.
12+ All types of declarative queries are based on the specification. It contains definitions of available filters, sorts, and aggregates.
1413
1514``` php
16- use Ensi\LaravelElasticQuery\Declarative \Agregating\AllowedAggregate;
17- use Ensi\LaravelElasticQuery\Declarative \Filtering\AllowedFilter;
18- use Ensi\LaravelElasticQuery\Declarative \Sorting\AllowedSort;
19- use Ensi\LaravelElasticQuery\Declarative \Specification\CompositeSpecification;
20- use Ensi\LaravelElasticQuery\Declarative \Specification\Specification;
15+ use Ensi\LaravelElasticQuerySpecification \Agregating\AllowedAggregate;
16+ use Ensi\LaravelElasticQuerySpecification \Filtering\AllowedFilter;
17+ use Ensi\LaravelElasticQuerySpecification \Sorting\AllowedSort;
18+ use Ensi\LaravelElasticQuerySpecification \Specification\CompositeSpecification;
19+ use Ensi\LaravelElasticQuerySpecification \Specification\Specification;
2120
2221class ProductSpecification extends CompositeSpecification
2322{
@@ -56,7 +55,7 @@ class ProductSpecification extends CompositeSpecification
5655}
5756```
5857
59- Примеры запросов для данной спецификации .
58+ Here are examples of queries for this specification .
6059``` json
6160{
6261 "sort" : [" +price" , " -rating" ],
@@ -75,30 +74,32 @@ class ProductSpecification extends CompositeSpecification
7574 }
7675}
7776```
78- Метод ` nested ` добавляет спецификации для вложенных документов. Имена фильтров, агрегатов и сортировок из них
79- экспортируются в глобальную область видимости без добавления каких-либо префиксов. Если для фильтров допустимо иметь
80- одинаковые имена, то для прочих компонентов нет.
77+
78+ The ` nested ` method adds specifications for nested documents. The names of filters, aggregates, and sorts are exported
79+ from them to the global scope without adding any prefixes. It is acceptable to have the same names for filters, but not
80+ for other components.
8181
8282``` php
8383$this->nested('nested_field', function (Specification $spec) { ... })
8484$this->nested('nested_field', new SomeSpecificationImpl());
8585```
8686
87- В спецификациях для вложенных документов могут использоваться только поля этих документов .
87+ In the specifications for nested documents, only the fields of these documents can be used .
8888
89- Допустимо добавлять несколько спецификаций для одного и того же поля типа ` nested ` .
89+ It is acceptable to add several specifications for the same ` nested ` field .
9090
91- Ограничения ` where* ` позволяют устанавливать дополнительные программные условия отбора, которые не могут быть изменены
92- клиентом. Ограничения, заданные в корневой спецификации, применяются всегда. Ограничения во вложенных спецификациях идут
93- только как дополнения к добавляемым в запрос фильтрам, агрегатам или сортировкам. Например, если во вложенной
94- спецификации нет ни одного активного фильтра, то в раздел фильтров запроса к Elasticsearch ограничения из этой
95- спецификации не попадут .
91+ The ` where* ` constraints allow you to set additional program selection conditions that cannot be changed by the client.
92+ The constraints specified in the root specification are always applied. Constraints in the nested specifications are
93+ only used as additions to filters, aggregates, or sorts added to the query. For example, if there is no active filter
94+ in the nested specification, then the constraints from this specification will not fall into the filters section
95+ of the Elasticsearch query .
9696
97- Метод ` allowedFilters ` определяет доступные для клиента фильтры. Каждый фильтр обязательно содержит уникальное в пределах
98- спецификации имя. В то же время, в корневой и вложенной спецификациях или в разных вложенных спецификациях, имена могут
99- повторяться. Все фильтры с одинаковыми именами будут заполнены одним значением из параметров запроса .
97+ The ` allowedFilters ` method determines the filters available to the client. Each filter must contain a unique name within
98+ the specification. At the same time, in the root and nested specifications or in different nested specifications,
99+ the names may be repeated. All filters with the same name will be filled with one value from the query parameters .
100100
101- Кроме имени самого фильтра можно отдельно задать имя поля в индексе, для которого он применяется, и значение по умолчанию.
101+ In addition to the name of the filter itself, you can separately specify the name of the field in the index for which
102+ it is applied, and the default value.
102103
103104``` php
104105$this->allowedFilters([AllowedFilter::exact('name', 'field')->default(500)]);
@@ -108,16 +109,16 @@ $this->allowedFilters(['name']);
108109$this->allowedFilters([AllowedFilter::exact('name', 'name')]);
109110```
110111
111- Виды фильтров
112+ Types of filters
112113
113114``` php
114- AllowedFilter::exact('name', 'field'); // Значение поля проверяется на равенство одному из заданных
115- AllowedFilter::exists('name', 'field'); // Проверяется, что поле присутствует в документе и имеет ненулевое значение
115+ AllowedFilter::exact('name', 'field'); // The field value is checked for equality to one of the specified
116+ AllowedFilter::exists('name', 'field'); // There is a check that the field is in the document and has a non-zero value.
116117```
117118
118- Доступные клиенту сортировки добавляются методом ` allowedSorts ` . Направление сортировки задается в ее имени .
119- Знак ` + ` или отсутствие знака соответствует порядку по возрастанию , ` - ` - порядку по убыванию .
120- По умолчанию используется сортировка по возрастанию с выбором минимального, в случае нескольких значений в поле .
119+ The sorts available to the client are added by the ` allowedSorts ` method. The sorting direction is set in its name .
120+ The sign ` + ` or the absence of a sign corresponds to the ascending order , ` - ` to the descending order .
121+ By default, ascending sorting is used with the minimum selection, if there are several values in the field .
121122
122123``` php
123124$this->allowedSorts([AllowedSort::field('name', 'field')]);
@@ -135,10 +136,10 @@ $this->allowedSorts([AllowedSort::field('name', 'field')->bySum()]);
135136$this->allowedSorts([AllowedSort::field('name', 'field')->byMedian()]);
136137```
137138
138- Для сортировки из вложенной спецификации учитываются все ограничения и активные фильтры из этой же спецификации .
139+ To sort from a nested specification, all constraints and active filters from the same specification are taken into account .
139140
140- Агрегаты объявляются методом ` allowedAggregates ` . Клиент в параметрах запроса указывает список имен агрегатов, результаты
141- которых он ожидает в ответе .
141+ Aggregates are declared with the ` allowedAggregates ` method. The client specifies in the query parameters a list of names
142+ of aggregates, the results of which he expects in the response .
142143
143144``` php
144145$this->allowedAggregates([AllowedAggregate::terms('name', 'field')]);
@@ -148,20 +149,20 @@ $this->allowedAggregates(['name']);
148149$this->allowedAggregates([AllowedAggregate::terms('name', 'name')]);
149150```
150151
151- Виды агрегатов
152+ Types of aggregates
152153
153154``` php
154155AllowedAggregate::terms('name', 'field'); // Get all variants of attribute values
155156AllowedAggregate::minmax('name', 'field'); // Get min and max attribute values
156157```
157158
158- Агрегаты из вложенных спецификаций добавляются в запрос к Elasticsearch со всеми ограничениями и активными фильтрами .
159+ Aggregates from nested specifications are added to the Elasticsearch query with all constraints and active filters .
159160
160- ## Поиск документов
161+ ## Search for documents
161162
162163``` php
163- use Ensi\LaravelElasticQuery\Declarative \SearchQueryBuilder;
164- use Ensi\LaravelElasticQuery\Declarative \QueryBuilderRequest;
164+ use Ensi\LaravelElasticQuerySpecification \SearchQueryBuilder;
165+ use Ensi\LaravelElasticQuerySpecification \QueryBuilderRequest;
165166
166167class ProductsSearchQuery extends SearchQueryBuilder
167168{
@@ -183,11 +184,11 @@ class ProductsController
183184}
184185```
185186
186- ## Расчет сводных показателей
187+ ## Calculation of summary indicators
187188
188189``` php
189- use Ensi\LaravelElasticQuery\Declarative \AggregateQueryBuilder;
190- use Ensi\LaravelElasticQuery\Declarative \QueryBuilderRequest;
190+ use Ensi\LaravelElasticQuerySpecification \AggregateQueryBuilder;
191+ use Ensi\LaravelElasticQuerySpecification \QueryBuilderRequest;
191192
192193class ProductsAggregateQuery extends AggregateQueryBuilder
193194{
0 commit comments