Skip to content

Instantly share code, notes, and snippets.

@bayareawebpro
Created October 16, 2019 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayareawebpro/ab53ccd81a4855b5267aead158c21670 to your computer and use it in GitHub Desktop.
Save bayareawebpro/ab53ccd81a4855b5267aead158c21670 to your computer and use it in GitHub Desktop.
<?php
namespace App;
use ScoutElastic\IndexConfigurator;
use ScoutElastic\Migratable;
class LocationIndex extends IndexConfigurator
{
use Migratable;
protected $name = "locations";
/**
* Configure Analyzers
* https://github.com/babenkoivan/scout-elasticsearch-driver
* https://www.elastic.co/guide/en/elasticsearch/guide/current/configuring-analyzers.html
* https://www.elastic.co/guide/en/elasticsearch/guide/current/asciifolding-token-filter.html
* https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenizer.html
* https://www.elastic.co/guide/en/elasticsearch/reference/6.7/search-aggregations-bucket-geohashgrid-aggregation.html
* https://hackernoon.com/elasticsearch-building-autocomplete-functionality-494fcf81a7cf
* @var array
*/
protected $settings = [
"analysis" => [
"analyzer" => [
"keyword" => [
"type"=> "custom",
"tokenizer"=> "keyword",
"filter"=> [
"lowercase",
"asciifolding"
],
],
"autocomplete" => [
"tokenizer" => "edge_ngram",
"filter" =>[
"lowercase",
"asciifolding"
],
],
"autocomplete_search" => [
"tokenizer" => "lowercase",
"filter"=> [
"lowercase",
"asciifolding"
],
]
],
"tokenizer" => [
"edge_ngram"=> [
"type"=> "edge_ngram",
"min_gram"=> 2,
"max_gram"=> 10,
"token_chars" => [
"letter",
"digit"
]
],
],
"aggregations" => [
"large-grid" => [
"geohash_grid" => [
"field" => "geo_point",
"precision" => 3,
]
]
],
]
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment