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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vendor/
.git/
.phpcs-cache
.idea/
*.log
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: ${{ matrix.elastic }}
security-enabled: false

- name: Composer
run: make composer
Expand All @@ -43,3 +44,5 @@ jobs:

- name: Tests
run: make tests
env:
ELASTICSEARCH_HOST: http://localhost:9200
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:8.2-cli

RUN apt-get update && apt-get install -y \
git \
unzip \
libcurl4-openssl-dev \
&& docker-php-ext-install curl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /app
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"require-dev": {
"ext-curl": "*",
"phpstan/phpstan": "^1.11.3",
"nette/tester": "v2.3.1",
"elasticsearch/elasticsearch": "^7",
"guzzlehttp/guzzle": "^6.3",
"nette/tester": "v2.5.7",
"elasticsearch/elasticsearch": "^9.0.0",
"guzzlehttp/guzzle": "^7.0",
"slevomat/coding-standard": "^8.0"
},
"autoload": {
Expand All @@ -34,10 +34,11 @@
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"php-http/discovery": true
}
},
"brach-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "2.0.0"
}
}
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
php:
build: .
volumes:
- .:/app
environment:
- ELASTICSEARCH_HOST=elasticsearch:9200
depends_on:
elasticsearch:
condition: service_healthy

elasticsearch:
image: elasticsearch:9.2.2
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- xpack.security.enrollment.enabled=false
- ES_JAVA_OPTS=-Xms512m -Xmx512m
ports:
- "9202:9200"
healthcheck:
test: curl -s http://localhost:9200 >/dev/null || exit 1
interval: 10s
timeout: 5s
retries: 10
6 changes: 1 addition & 5 deletions src/Aggregation/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@
class Range implements LeafAggregationInterface
{

private \Spameri\ElasticQuery\Aggregation\RangeValueCollection $ranges;


public function __construct(
private string $field,
private bool $keyed = false,
\Spameri\ElasticQuery\Aggregation\RangeValueCollection $rangeValueCollection = null,
private \Spameri\ElasticQuery\Aggregation\RangeValueCollection $ranges = new \Spameri\ElasticQuery\Aggregation\RangeValueCollection(),
)
{
$this->ranges = $rangeValueCollection ?: new \Spameri\ElasticQuery\Aggregation\RangeValueCollection();
}


Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ResponseCouldNotBeMapped.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ResponseCouldNotBeMapped extends \InvalidArgumentException
public function __construct(
string $message,
int $code = 0,
\Throwable $previous = null,
\Throwable|null $previous = null,
)
{
parent::__construct((string) \json_encode($message), $code, $previous);
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/Settings/Mapping/FieldSeparator.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

declare(strict_types = 1);
declare(strict_types = 1);

namespace Spameri\ElasticQuery\Mapping\Settings\Mapping;

class FieldSeparator
Expand Down
2 changes: 2 additions & 0 deletions src/Response/Result/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Version
public const ELASTIC_VERSION_ID_67 = 60700;
public const ELASTIC_VERSION_ID_7 = 70000;
public const ELASTIC_VERSION_ID_8 = 80000;
public const ELASTIC_VERSION_ID_9 = 90000;
public const ELASTIC_VERSION_ID_10 = 100000;

private int $id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class AggregationCollection extends \Tester\TestCase
public function setUp(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'PUT');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}


Expand Down Expand Up @@ -161,7 +160,7 @@ class AggregationCollection extends \Tester\TestCase
);

$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
Expand All @@ -178,21 +177,18 @@ class AggregationCollection extends \Tester\TestCase
$result = $resultMapper->map(\json_decode($response, true));
\Tester\Assert::type(\Spameri\ElasticQuery\Response\ResultSearch::class, $result);
});

\curl_close($ch);
}


public function tearDown(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}

}
Expand Down
10 changes: 3 additions & 7 deletions tests/SpameriTests/ElasticQuery/Aggregation/Avg.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class Avg extends \Tester\TestCase
public function setUp(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'PUT');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}


Expand Down Expand Up @@ -64,7 +63,7 @@ class Avg extends \Tester\TestCase
);

$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
Expand All @@ -81,21 +80,18 @@ class Avg extends \Tester\TestCase
$result = $resultMapper->map(\json_decode($response, true));
\Tester\Assert::type(\Spameri\ElasticQuery\Response\ResultSearch::class, $result);
});

\curl_close($ch);
}


public function tearDown(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}

}
Expand Down
10 changes: 3 additions & 7 deletions tests/SpameriTests/ElasticQuery/Aggregation/Filter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class Filter extends \Tester\TestCase
public function setUp(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'PUT');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}


Expand Down Expand Up @@ -76,7 +75,7 @@ class Filter extends \Tester\TestCase
);

$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
Expand All @@ -93,21 +92,18 @@ class Filter extends \Tester\TestCase
$result = $resultMapper->map(\json_decode($response, true));
\Tester\Assert::type(\Spameri\ElasticQuery\Response\ResultSearch::class, $result);
});

\curl_close($ch);
}


public function tearDown(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}

}
Expand Down
10 changes: 3 additions & 7 deletions tests/SpameriTests/ElasticQuery/Aggregation/Histogram.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class Histogram extends \Tester\TestCase
public function setUp(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'PUT');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}


Expand Down Expand Up @@ -65,7 +64,7 @@ class Histogram extends \Tester\TestCase
);

$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
Expand All @@ -82,21 +81,18 @@ class Histogram extends \Tester\TestCase
$result = $resultMapper->map(\json_decode($response, true));
\Tester\Assert::type(\Spameri\ElasticQuery\Response\ResultSearch::class, $result);
});

\curl_close($ch);
}


public function tearDown(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class LeafAggregationCollection extends \Tester\TestCase
public function setUp(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'PUT');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}


Expand Down Expand Up @@ -164,7 +163,7 @@ class LeafAggregationCollection extends \Tester\TestCase
);

$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . $document->index . '/_search');
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'GET');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
Expand All @@ -181,21 +180,18 @@ class LeafAggregationCollection extends \Tester\TestCase
$result = $resultMapper->map(\json_decode($response, true));
\Tester\Assert::type(\Spameri\ElasticQuery\Response\ResultSearch::class, $result);
});

\curl_close($ch);
}


public function tearDown(): void
{
$ch = \curl_init();
\curl_setopt($ch, \CURLOPT_URL, 'localhost:9200/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_URL, \ELASTICSEARCH_HOST . '/' . self::INDEX);
\curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE');
\curl_setopt($ch, \CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

\curl_exec($ch);
\curl_close($ch);
}

}
Expand Down
Loading