Download the PHP package shaozeming/laravel-elasticsearch without Composer

On this page you can find all versions of the php package shaozeming/laravel-elasticsearch. 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 laravel-elasticsearch

Elasticsearch for laravel5.* or lumen


Installing

Overview

快速使用

同时,您仍然可以使用所有Eloquent集合功能:

工作原理

搜索时候,将从Es数据库中索引数据,并返回Eloquent对象数据

Setup

开始使用ShaoZeMing\LaravelElasticsearch之前,请确保已安装Elasticsearch.

Laravel

And publish the config file:

if you want to use facade mode, you can register a facade name what you want to use, for example LaravelElasticsearch:

lumen

vendor/shaozeming/laravel-elasticsearch/config/elasticsearch.php.php 拷贝到项目根目录/config目录下,并将文件名改成elasticsearch.php

Configuration

Eloquent模型有一些额外的方法,可以使用Elasticsearch更轻松地索引模型的数据。 虽然您可以通过Elasticsearch API构建索引和映射,但您也可以使用一些辅助方法直接从模型构建索引和类型。

如果您想要一种简单的方法来创建索引,ShaoZeMing\LaravelElasticsearch模型具有以下方法:

若需要自定义分析器,您可以在模型中设置indexSettings属性并从那里定义分析器:

关于映射,您可以在模型中设置mappingProperties属性,并使用一些映射函数:

根据映射属性设置模型的类型映射:

删除映射:

重建映射:

获取类型映射并检查它是否存在。

设置项目索引名称

配置文件 default_index key设置:

Indexing Documents

索引整个模型数据 addAllToIndex:

索引多条:

索引单条:

您还可以重新索引整个模型:

Searching

三种搜索方式

简单搜索

第一种方法是搜索所有字段的简单术语搜索。

基于查询的搜索

第二种是基于查询的搜索,以满足更复杂的搜索需求:

Example:

这是可用参数列表:

原始查询

最终方法是将发送到Elasticsearch的原始查询。在Elasticsearch中搜索记录时,此方法将为您提供最大的灵活性,搜索语法请查看ES官方文档

这条查询相当于:

搜索结果集合

当您在ShaoZeMing\LaravelElasticsearch模型上搜索时,您将获得具有一些特殊功能的搜索集合。

您可以获得总点击次数:

访问分片数组:

获得最高分:

访问超时布尔属性:

并访问take属性:

并访问搜索聚合 - 有关详细信息,请参阅聚合: - See Aggregations for details:

Search Collection Documents

使用isDocument函数检查并查看模型是否为文档:

检查Elasticsearch分配给此文档的文档分数

拆分搜索集合

与Illuminate\Support\Collection类似,chunk方法将ShaoZeMing\LaravelElasticsearch集合分解为给定大小的多个较小的集合:

使用ShaoZeMing\LaravelElasticsearch之外的搜索集合

如果您正在处理来自ShaoZeMing\LaravelElasticsearch外部的原始搜索数据,则可以使用ShaoZeMing\LaravelElasticsearch搜索结果集合将该数据转换为集合。

其他设置

文档索引主键id

将使用设置为您的Eloquent模型的primaryKey作为Elasticsearch文档的ID。

文档数据体结构

默认情况下,将使用整个属性数组作为Elasticsearch文档。 但是,如果要自定义搜索文档的结构,可以设置getIndexDocumentData函数,该函数返回您自己的自定义文档数组。

将与自定义集合模型一起使用

如果您在Eloquent模型中使用自定义集合,则只需将ElasticquentCollectionTrait添加到集合中,这样就可以使用addToIndex。


All versions of laravel-elasticsearch with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/container Version ~4.2|^5
illuminate/database Version ~4.2|^5
illuminate/config Version ~4.2|^5
nesbot/carbon Version ~1.0|~2
elasticsearch/elasticsearch Version ~6.1
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 shaozeming/laravel-elasticsearch contains the following files

Loading the files please wait ....