配置内置分析器
编辑配置内置分析器编辑
内置分析器可以直接使用,无需任何配置。但是,其中一些分析器支持配置选项来更改其行为。例如,standard
分析器可以配置为支持停用词列表。
response = client.indices.create( index: 'my-index-000001', body: { settings: { analysis: { analyzer: { std_english: { type: 'standard', stopwords: '_english_' } } } }, mappings: { properties: { my_text: { type: 'text', analyzer: 'standard', fields: { english: { type: 'text', analyzer: 'std_english' } } } } } } ) puts response response = client.indices.analyze( index: 'my-index-000001', body: { field: 'my_text', text: 'The old brown cow' } ) puts response response = client.indices.analyze( index: 'my-index-000001', body: { field: 'my_text.english', text: 'The old brown cow' } ) puts response
PUT my-index-000001 { "settings": { "analysis": { "analyzer": { "std_english": { "type": "standard", "stopwords": "_english_" } } } }, "mappings": { "properties": { "my_text": { "type": "text", "analyzer": "standard", "fields": { "english": { "type": "text", "analyzer": "std_english" } } } } } } POST my-index-000001/_analyze { "field": "my_text", "text": "The old brown cow" } POST my-index-000001/_analyze { "field": "my_text.english", "text": "The old brown cow" }