Download the PHP package savingfor/elasticsearch-query-builder without Composer

On this page you can find all versions of the php package savingfor/elasticsearch-query-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package elasticsearch-query-builder

快速流畅的 PHP API 构建和执行 ElasticSearch 查询

这个包是 ElasticSearch 的轻量级查询构建器。它是专门为我们的elasticsearch-search-string-parser构建的,因此它涵盖了大多数使用方法,但会缺少部分某些功能。如果您需要任何特定的东西,也可以进行补充,这一点不胜荣幸。

安装

请确保您安装好composer

基本用法

您真正需要与之交互的唯一类是Savingfor\ElasticsearchQueryBuilder\Builder该类。它需要\Elasticsearch\Client在构造函数中传递引用。通过 ElasticSearch SDK文档 了解更多PHP-ElasticSearch更多信息。

新增搜索查询

$builder->addQuery()方法可用于将任何可用Query类型添加到构建器。可用的查询类型可以在下面或src/Queries此 repo 的目录中找到。每个Query都有一个静态create()方法来传递其最重要的参数。

可以使用以下查询类型:

TermQuery

官方文档使用详情

RangeQuery

官方文档使用详情

BoolQuery

官方文档使用详情

ExistsQuery

官方文档使用详情

MatchQuery

官方文档使用详情

MultiMatchQuery

官方文档使用详情

NestedQuery

官方文档使用详情

WildcardQuery

官方文档使用详情

多个搜索查询

多个addQuery()调用可以链接在一个上Builder。多次调用中,它们将被添加到BoolQuery中。通过将第二个参数传递给该addQuery()方法,您可以选择不同的出现类型:

有关布尔查询及其出现类型的更多信息,请参阅Elasticsearch文档

聚合查询

$builder->addAggregation()方法可用于将任何可用Aggregation 添加到构建器。可用的聚合类型可以在下面或src/Aggregations此 repo 的目录中找到。每个Aggregation都有一个静态create()方法来传递其最重要的参数,有时还有一些额外的方法。

可以使用以下聚合查询类型:

TermsAggregation

官方文档使用详情

CardinalityAggregation

官方文档使用详情

FilterAggregation

官方文档使用详情

MaxAggregation

官方文档使用详情

MinAggregation

官方文档使用详情

ReverseNestedAggregation

官方文档使用详情

TopHitsAggregation

官方文档使用详情

添加排序

Builder和一些聚合查询)有一个addSort()方法,它需要一个Sort实例来对结果进行排序。您可以在ElasticSearch 文档中阅读有关排序工作原理的更多信息。

返回特定字段

fields()方法可用于从结果文档中请求特定字段,而无需返回整个_source条目。您可以在ElasticSearch 文档中阅读有关 fields 参数细节的更多信息。

分页

最后Builder还提供了相应的 ElasticSearch 搜索参数的方法size()from()这些可用于构建分页搜索。看看下面的例子来大致了解一下:

License

MIT


All versions of elasticsearch-query-builder with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
elasticsearch/elasticsearch Version 7.12
friendsofphp/php-cs-fixer Version 2.17
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package savingfor/elasticsearch-query-builder contains the following files

Loading the files please wait ....