Created
August 23, 2019 07:11
-
-
Save Narazaka/a58cdc0ae1b687c5ca8248dc99a62a7f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// https://qiita.com/shin_hayata/items/41c07923dbf58f13eec4 | |
// http://319ring.net/blog/archives/2906/ | |
// https://medium.com/hello-elasticsearch/elasticsearch-833a0704e44b | |
// http://blog.shibayu36.org/entry/2016/08/31/110000 | |
// https://gist.github.com/karmi/4526141 | |
export const settings = { | |
index: { | |
analysis: { | |
tokenizer: { | |
ja_text_tokenizer: { | |
type: "kuromoji_tokenizer", | |
mode: "search", | |
}, | |
roman_text_tokenizer: { | |
type: "ngram", | |
min_gram: 2, | |
max_gram: 3, | |
}, | |
}, | |
analyzer: { | |
original_form_analyzer: { | |
type: "custom", | |
tokenizer: "ja_text_tokenizer", | |
filter: ["kuromoji_stemmer"], | |
}, | |
normalize_form_analyzer: { | |
type: "custom", | |
tokenizer: "ja_text_tokenizer", | |
char_filter: ["icu_normalizer", "kuromoji_iteration_mark"], | |
filter: ["kuromoji_baseform", "kuromoji_part_of_speech", "ja_stop", "kuromoji_number", "kuromoji_stemmer"], | |
}, | |
reading_form_analyzer: { | |
type: "custom", | |
tokenizer: "ja_text_tokenizer", | |
char_filter: ["icu_normalizer", "kuromoji_iteration_mark"], | |
filter: ["kuromoji_part_of_speech", "ja_stop", "kuromoji_readingform", "kuromoji_stemmer"], | |
}, | |
roman_analyzer: { | |
tokenizer: "roman_text_tokenizer", | |
}, | |
}, | |
}, | |
}, | |
}; | |
export const integer = { type: "integer" }; | |
export const float = { type: "float" }; | |
export const boolean = { type: "boolean" }; | |
export const date = { type: "date" }; | |
export const keyword = { type: "keyword" }; | |
export const nested = { type: "nested" }; | |
export const text = { | |
type: "text", | |
analyzer: "original_form_analyzer", | |
fields: { | |
strict: { | |
type: "keyword", | |
}, | |
normalized: { | |
type: "text", | |
analyzer: "normalize_form_analyzer", | |
}, | |
kana: { | |
type: "text", | |
analyzer: "reading_form_analyzer", | |
}, | |
}, | |
}; | |
export const idtext = { | |
type: "keyword", | |
fields: { | |
fuzzy: { | |
type: "text", | |
analyzer: "roman_analyzer", | |
}, | |
}, | |
}; | |
export const extractCharRefs = (str: string) => | |
str | |
.replace(/"/g, '"') | |
.replace(/</g, '<') | |
.replace(/>/g, '>') | |
.replace(/&/g, '&') | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment