Last active
June 15, 2019 17:53
-
-
Save jgram925/c7b1ac098444eaa8d1cf3e7ed2da286b to your computer and use it in GitHub Desktop.
Elasticsearch-DSL: Analyzer Setup for Ngram Partial Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the analyzer which will tokenize any text fields which it is passed to. | |
This example also creates lowercase and uppercase tokens with html stripped. | |
my_analyzer = analyzer("my_analyzer", | |
tokenizer = tokenizer("trigram", nGram, min_gram=3, max_gram=10), | |
filter = ['standard', 'lowercase', 'uppercase'], | |
char_filter = [ "html_strip" ] | |
) | |
class ArticleIndex(Document): | |
pk = Integer() | |
title = Text(analyzer=my_analyzer) | |
content = Text() | |
class Index: | |
name = 'article-index' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment