2017 © Pedro PelĂĄez
 

cakephp-plugin cakephp-elastic-search

CakePHP pages plugins

image

3xw/cakephp-elastic-search

CakePHP pages plugins

  • Thursday, July 26, 2018
  • by awallef
  • Repository
  • 3 Watchers
  • 1 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 47 % Grown

The README.md

cakephp-elastic-search plugin for CakePHP

This plugin allows you deal with ES, (*1)

Installation

You can install this plugin into your CakePHP application using composer., (*2)

The recommended way to install composer packages is:, (*3)

composer require 3xw/elastic-search

Load it in your config/boostrap.php, (*4)

Plugin::load('Trois/ElasticSearch');

Setup

in app.php add at least one connection:, (*5)

'Datasources' => [
    'elastic' => [
      'className' => 'Cake\ElasticSearch\Datasource\Connection',
      'driver' => 'Cake\ElasticSearch\Datasource\Connection',
      'host' => 'localhost',
      'port' => 6379,
    ],
    ...
]

Mapping

The shell will ask you a mapping template. Follow offical doc native elasticsearch mapping format to create your own index mapping or use default one which the prompt proposes you: vendor/3xw/cakephp-elastic-search/templates/mapping.json, (*6)

{
    "settings": {
    "analysis": {
      "filter": {
        "french_elision": {
          "type":"elision",
          "articles_case": true,
          "articles": [
            "l", "m", "t", "qu", "n", "s",
            "j", "d", "c", "jusqu", "quoiqu",
            "lorsqu", "puisqu","t"
          ]
        },
        "french_stop": {
          "type":       "stop",
          "stopwords":  "_french_"
        },
        "french_keywords": {
          "type":       "keyword_marker",
          "keywords":   [
            "Prométerre",
            "Agrivit","Ecoprest","Estimapro","Fidasol","Fiprom",
            "Fondation rurale de prévoyance","FRP",
            "Mandaterre",
            "Office de crédit agricole","OCA",
            "Proconseil","Proterroir","SAD","SRPJ","Sofia SA"
          ]
        },
        "french_stemmer": {
          "type":       "stemmer",
          "language":   "light_french"
        }
      },
      "analyzer": {
        "french": {
          "tokenizer":  "standard",
          "filter": [
            "french_elision",
            "lowercase",
            "french_stop",
            "french_keywords",
            "french_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "items": {
      "properties": {
        "foreign_key": { "type": "integer"},
        "model": { "type": "keyword"},
        "title": {"type": "completion", "analyzer":"french", "max_input_length": 255},
        "content": {"type": "text"}
      }
    }
  }
}

Behavior

set up your behavior as you wish, (*7)

$this->addBehavior(\Trois\ElasticSearch\ORM\Behavior\SyncWithESBehavior::class,[
  'index' => 'App\Model\Index\ItemsIndex',
  'primaryKey' => 'foreign_key', // string or callable
  'translate' => false, // property name if yes ex: locale
  'staticMatching' => [
    'model' => 'Posts'
  ], // or [keyN => valueN/callableN]
  'mapping' => [ // properties => 1. Array: entity field(s) || properties => 2. String: static value or callable
    'title' => new \Trois\ElasticSearch\ORM\CompletionConstructor(['title'],[
      'contexts' => [
        'model' => 'Posts'
      ],
     ]),
    'content' => ['header','content']
  ],
  'deleteDocument' => true,
  'separator' => ' - '
]);

Shell

Create indexes, (*8)

bin/cake elastic create [indexName] [mappingFile.json]

------
Execute create index w/ mapping file Task.

Usage:
cake trois/elastic_search.elastic create [-c] [-h] [-q] [-r 1] [-s 5] [-v]

Options:

--connection, -c  The Elestic Search connection to use
--help, -h        Display this help.
--quiet, -q       Enable quiet output.
--replicas, -r    The index number of replicas. Default is 1
                  (default: 1)
--shards, -s      The index number of shards. Default is 5
                  (default: 5)
--verbose, -v     Enable verbose output.

Get index info, (*9)

bin/cake elastic info [indexName]

------
Execute info on index Task.

Usage:
cake trois/elastic_search.elastic info [-c] [-h] [-q] [-v]

Options:

--connection, -c  The Elestic Search connection to use
--help, -h        Display this help.
--quiet, -q       Enable quiet output.
--verbose, -v     Enable verbose output.

Delete index, (*10)

bin/cake elastic delete [indexName]

------
Execute delete index Task.

Usage:
cake trois/elastic_search.elastic delete [-c] [-h] [-q] [-v]

Options:

--connection, -c  The Elestic Search connection to use
--help, -h        Display this help.
--quiet, -q       Enable quiet output.
--verbose, -v     Enable verbose output.

Import entire table, (*11)

bin/cake elastic import [indexName] [tableName]
------
Execute import on index with table.

Usage:
cake trois/elastic_search.elastic import [-c] [-h] [-q] [-v]

Options:

--connection, -c  The Elestic Search connection to use
--help, -h        Display this help.
--quiet, -q       Enable quiet output.
--verbose, -v     Enable verbose output.

The Versions

26/07 2018

dev-master

9999999-dev

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

26/07 2018

3.6.0.0

3.6.0.0

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

26/07 2018

3.5.0.11

3.5.0.11

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

25/07 2018

3.5.0.10

3.5.0.10

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

15/05 2018

3.5.0.9

3.5.0.9

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

15/05 2018

3.5.0.8

3.5.0.8

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

11/05 2018

3.5.0.7

3.5.0.7

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

09/05 2018

3.5.0.6

3.5.0.6

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

08/05 2018

3.5.0.5

3.5.0.5

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

08/05 2018

3.5.0.4

3.5.0.4

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

08/05 2018

3.5.0.3

3.5.0.3

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

08/05 2018

3.5.0.2

3.5.0.2

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

07/05 2018

3.5.0.1

3.5.0.1

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires

02/03 2018

3.5.0.0

3.5.0.0

CakePHP pages plugins

  Sources   Download

The Requires

 

The Development Requires