承接 tamayo/stretchy 相关项目开发

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

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

tamayo/stretchy

最新稳定版本:2.0.0

Composer 安装命令:

composer require tamayo/stretchy

包简介

Elastic Search integration for Laravel 5.0

README 文档

README

Build Status

Stretchy in an Elasticsearch integration for Laravel 5.

Heavily Inspired by Query Builder and Schema of laravel.

Description on going.

Version

2.0.0 - Alpha

Documentation

The current documentation is at stretchy.readthedocs.org.

#Installation

###Requirements

  • PHP 5.5.9+

Installing with Composer

  1. In your composer.json, add the dependency: "tamayo/stretchy": "2.0.0"

  2. Add the Stretchy service provider in your app.config:

        'Tamayo\Stretchy\StretchyServiceProvider'
  1. Add the following aliases:
		'Index'    => 'Tamayo\Stretchy\Facades\Index',
		'Document' => 'Tamayo\Stretchy\Facades\Document',
		'Stretchy' => 'Tamayo\Stretchy\Facades\Stretchy'
  1. (Optional) If you want to override the default configuration:
php artisan config:publish tamayo/stretchy

Located in your laravel config directory: packages/tamayo/stretchy/config.php

##Quick Examples ####Create Index To create a basic index just do the following:

Index::create('foo');

If you want to specify shards and replicas:

Index::create('foo', function($index)
	{
		$index->shards(5);
		$index->replicas(1);
	});

####Delete Index

Index::delete('foo');

####Document indexing

Document::index('foo')
    ->type('tweet')
    ->id(13) // Optional (if not specified elastic will generate an unique id)
    ->insert([
        'username' => '@ericktamayo',
        'tweet'    => 'Hello world!'
    ]);

####Update a document

Document::index('foo')
    ->type('tweet')
    ->id(13)
    ->update(['tweet' => 'Hello world!!!']);

####Get a document

Document::index('foo')->type('tweet')->Id(13)->get();

####Delete a document

Document::index('foo')->type('tweet')->Id(13)->delete();

###Searching

#####Match Query

Stretchy::search('foo')->match('bar', 'Stretchy')->get();

To provide additional parameters:

Stretchy::search('foo')
	->match('bar', 'baz', ['operator' => 'and', 'zero_terms_query' => 'all'])
	->get();

or

Stretchy::search('foo')
	->match('bar', 'Stretchy', function($match)
	{
		$match->operator('and');
		$match->zeroTermsQuery('all');
		$match->cutoffFrequency(0.001);
	})
	->get();

#####Term Query

Stretchy::search('foo')->term('bar', 'baz')->get();

To provide additional parameters:

Stretchy::search('foo')->term('bar', 'baz', ['boost' => 2])->get();

or

Stretchy::search('foo')
	->term('bar', 'baz', function($term)
	{
		$term->boost(2);
	})
	->get();

#####Bool Query

Stretchy::search('foo')
	->bool(function($query)
	{
		$query->must(function($must)
		{
			$must->match('bar', 'baz');
		});

		$query->mustNot(function($mustNot)
		{
			$mustNot->match('bar', 'qux');
		});

		$query->should(function($should)
		{
			$should->match('bar', 'bah');
		});

		$query->minimumShouldMatch(1);
	})
	->get();

More examples can be found in the documentation.

Roadmap

  • Documentation
  • Make the library to be independent from Laravel components
  • PutMapping API

###Author Erick Tamayo - ericktamayo@gmail.com - @ericktamayo

License

MIT

统计信息

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

GitHub 信息

  • Stars: 45
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-01-01