View definition

(*IndexMapping).AddCustomAnalyzer

Defined in github.com/blevesearch/bleve/mapping_index.go

Description

AddCustomAnalyzer defines a custom analyzer for use in this mapping. The config map must have a "type" string entry to resolve the analyzer constructor. The constructor is invoked with the remaining entries and returned analyzer is registered in the IndexMapping.

bleve comes with predefined analyzers, like github.com/blevesearch/bleve/analysis/analyzers/custom_analyzer. They are available only if their package is imported by client code. To achieve this, use their metadata to fill configuration entries:

import (
    "github.com/blevesearch/bleve/analysis/analyzers/custom_analyzer"
    "github.com/blevesearch/bleve/analysis/char_filters/html_char_filter"
    "github.com/blevesearch/bleve/analysis/token_filters/lower_case_filter"
    "github.com/blevesearch/bleve/analysis/tokenizers/unicode"
)

m := bleve.NewIndexMapping()
err := m.AddCustomAnalyzer("html", map[string]interface{}{
    "type": custom_analyzer.Name,
    "char_filters": []string{
        html_char_filter.Name,
    },
    "tokenizer":     unicode.Name,
    "token_filters": []string{
        lower_case_filter.Name,
        ...
    },
})

AddCustomAnalyzer is referenced in 6 repositories

github.com/pmezard/apec github.com/ekanite/ekanite github.com/gophergala/ging

...