Reasonably new to ElasticSearch / NEST - I have a property on a mapping that holds UK postcodes (eg DT5 2HW, BB1 9DR). At the moment, I have the following code:-
if (!client.IndexExists("user").Exists)
{
client.CreateIndex("user", c => c.Mappings(
m => m.Map<User>(
mp => mp.AutoMap()
)
)
);
}
I'm trying to find the correct place to specify an analyzer when creating a fluent mapping (so I can implement what's being done here), but:-
- calling
mp.AutoMap().Analyzer()
is marked as deprecated / to be removed in 6.0 with a warning that default analyzers are to be removed at the type level, and need to be specified at the index or field level (sidenote: by field, do they mean property?) Analyzer()
is not available in Intellisense after eitherKeyword()
orName()
Is it just not possible to do so via a fluent mapping? Does this mean that I have to specify the available analyzers via CreateIndex -> Settings -> Analysis, then specify the Analyzers to use on a property level with attributes on the POCO?
I feel like I've gone fundamentally wrong somewhere - any pointers would be greatly appreciated!
.String( ... )
and if you're doing something like an ngram, keyword search, etc. with it, it has becmome.Text(...)
- Llamakeyword
data types are not analyzed and cannot have analysis applied; in 5.0 thestring
data type was split intotext
(analyzed) andkeyword
(not analyzed): elastic.co/blog/strings-are-dead-long-live-strings.keyword
data types can have a normalizer applied in 5.2+ as it is often useful to normalize data in some way e.g. lowercase it, whilst still leveraging thedoc_values
underlying columnar data structure. The normalizer is restricted to producing a single token however (think of it as a restricted analyzer if you will). - Russ Cam