Skip to content

Instantly share code, notes, and snippets.

@ritec
Forked from aaronsakowski/model.rb
Created July 30, 2021 20:24
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 ritec/759d5db42a74a8f16a315b61020ea059 to your computer and use it in GitHub Desktop.
Save ritec/759d5db42a74a8f16a315b61020ea059 to your computer and use it in GitHub Desktop.
Searchkick autocomplete by token
searchkick autocomplete: ["name"],
settings: {
analysis: {
analyzer: {
searchkick_keyword: {
type: "custom",
tokenizer: "keyword",
filter: ["lowercase", "snowball"]
},
default_index: {
type: "custom",
tokenizer: "standard",
# synonym should come last, after stemming and shingle
# shingle must come before snowball
filter: ["standard", "lowercase", "asciifolding", "stop", "searchkick_index_shingle", "snowball"]
},
searchkick_search: {
type: "custom",
tokenizer: "standard",
filter: ["standard", "lowercase", "asciifolding", "stop", "searchkick_search_shingle", "snowball"]
},
searchkick_search2: {
type: "custom",
tokenizer: "standard",
filter: ["standard", "lowercase", "asciifolding", "stop", "snowball"]
},
searchkick_autocomplete_index: {
type: "custom",
tokenizer: "standard",
filter: [ "standard", "lowercase", "asciifolding", "searchkick_autocomplete_ngram" ]
},
searchkick_autocomplete_search: {
type: "custom",
tokenizer: "standard",
filter: [ "standard", "lowercase", "asciifolding"]
},
searchkick_suggest_index: {
type: "custom",
tokenizer: "standard",
filter: ["lowercase", "asciifolding", "searchkick_suggest_shingle"]
}
},
filter: {
searchkick_autocomplete_ngram: {
type: "edgeNGram",
max_gram: 15,
min_gram: 1
},
searchkick_index_shingle: {
type: "shingle",
token_separator: ""
},
# lucky find http://web.archiveorange.com/archive/v/AAfXfQ17f57FcRINsof7
searchkick_search_shingle: {
type: "shingle",
token_separator: "",
output_unigrams: false,
output_unigrams_if_no_shingles: true
},
searchkick_suggest_shingle: {
type: "shingle",
max_shingle_size: 5
}
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment