Skip to content

Instantly share code, notes, and snippets.

@Anahkiasen
Created January 30, 2015 10:18
Show Gist options
  • Save Anahkiasen/2f188919d9848f6d13c0 to your computer and use it in GitHub Desktop.
Save Anahkiasen/2f188919d9848f6d13c0 to your computer and use it in GitHub Desktop.
<?php
namespace Remindme\Search\Indexes;
use ElasticSearcher\Abstracts\IndexAbstract;
class TagsIndex extends IndexAbstract
{
/**
* @return string
*/
public function getName()
{
return 'tags';
}
/**
* @return array
*/
public function getTypes()
{
return array(
'tags' => array(
'properties' => array(
'id' => ['type' => 'integer'],
'tag' => ['type' => 'string', 'analyzer' => 'ngram_analyzer'],
),
),
);
}
/**
* @return array
*/
public function getBody()
{
$body = parent::getBody();
$body['settings'] = array(
'filter' => array(
'ngram_filter' => array(
'type' => 'nGram',
'min_gram' => 2,
'max_gram' => 20
)
),
'analyzer' => array(
'ngram_analyzer' => array(
'type' => 'custom',
'tokenizer' => 'whitespace',
'filter' => array(
'lowercase',
'asciifolding',
'ngram_filter'
)
)
),
);
return $body;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment