承接 aqarmap/elastic-repository 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aqarmap/elastic-repository

Composer 安装命令:

composer require aqarmap/elastic-repository

包简介

elastic search active repository package

README 文档

README

Packagist License

🎉 Elasticsearch Repository Package

Elasticsearch Repository is a simple, smart implementation of Active Repository for Elasticsearch.

🔥 Features

  • provide active repository pattern over your elasticsearch indices, types.
  • bring query builder into your elasticsearch repositories.
  • Minimize lines of code for building elasticsearch queries with system with big business logic.
  • Prevent code duplication.
  • Reduce potential programming errors.

❕ Installation

grap it via composer

composer require mustafah15/elastic-repository

integration

Elasticsearch Repository package is framework-agnostic and as such can be integrated easily natively or with your favorite framework.

✨ Usage

  • Extend ElasticRepository class as a repository for your type or index.
class schoolsRepository extends ElasticRepository 
{
    // method contains some bussiness logic 
    public function returnQueryWherename()
    {
        $this->where('name', 'EGSchool', 0.5)->getResultQuery();
    }
}

📋 Documentation

ElasticRepository

when you extend ElasticRepository class you will have get various functionality

setIndex(), setType()

The setIndex() and setType() methods for setting up your index name and type name into Repository:

setSort()

The setSort() method adds main sort criteria for the query: sorting with _score by default when adding score function

// pass field name to sort by 
$queryBuilder->setSort('fieldName');

setOrder()

The setOrder() method to specify sort direction:

$queryBuilder->setSort('fieldName')->setOrder('desc');

setTransformer($transformer)

The setTransformer($transformer) to add transformer for your result transformer must implement TransformerContract

get()

method get() to get result from your final query after building it using query builder:

getResultWithScore()

The getResultWithScore($scoreFunction) method to get results after adding a score function: takes Query\FunctionScore $functionScore as a parameter to be applied to your results

getResultQuery()

the getResultQuery() return Query object

getResultQueryWithScore($scoreFunction)

takes Query\FunctionScore $functionScore as a parameter to apply scoring to your query

QueryBuilder

Every ElasticRepository class have it's own query builder which have a lot of operations and functionlity that you can use.

where(), whereNot()

The where() and whereNot() methods adding must and must not to the main filter:

//attribute paramter then the expected value and optional value for the field boost
$queryBuilder->where($attribute, $value = null, $boost = 1.0);

whereIn(), whereNotIn()

The whereIn() and whereNotIn() methods adding Range to the main filter:

//attribute paramter then a optional value for the fields from and to
$queryBuilder->whereIn($attribute, $from = '', $to = '');

exist('fieldName')

$queryBuilder->exist('fieldName');

match($attribute, $keyword)

$queryBuilder->match('fieldName', $keywordToMatch);

TODO

  • caching support

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固