Version 1.x of Next/Elasticsearch .Net client was much richer with examples on how to set up the indexes and perform searches, etc. I've noticed this version seems to only give unit test style examples. Are there actual c#.net code examples to look at?
Reason i ask is upgrading from 1.x to 2.x (or 5) is so dramatically different in indexing, etc and i am having a very difficult time trying to figure out how to build the indexes, for example, using Nest. I understand much of it is to be used with AutoMap(), given the configuration options are supposed to be inferred or explicitly mapped using field attributes, but my indexes are much more complex. I have a lot of nested objects and fields that have multiple properties, based on very specific analizers, etc.
For example, i have the need to map an index of artists like this (multifield):
The documentation is a living entity so is a constant work in progress. We pushed out documentation for 2.x at the time the 2.x client was released and this includes details on automapping.
We have plans to add further details on analysis and other APIs as well as add sections for getting started with querying, aggregations, etc. and reorganise the current documentation.
Here's what your mapping would look like in 2.x (assuming the following models):
public class MyDocument
{
public Artist Artist { get; set; }
}
public class Artist
{
public string Name { get; set; }
}
client.Map<MyDocument>(m => m
// let NEST infer the Elasticsearch field types for your POCO
// based on the .NET property types. This is akin to .MapFromAttributes() in
// NEST 1.x
.AutoMap()
// Now, override any inferred mappings
.Properties(p => p
.Object<Artist>(x => x
.AutoMap()
.Name(n => n.Artist)
.Properties(pp => pp
.String(s => s
.Name(o => o.Name)
.Analyzer("nameAnalyzer")
.Norms(n => n.Enabled(false))
.Fields(ff => ff
.String(ss => ss
.Name("ti")
.Analyzer("titleAnalyzer")
.Norms(n => n.Enabled(false))
)
.String(ss => ss
.Name("wo")
.Analyzer("titleWordAnalyzer")
.Norms(n => n.Enabled(false))
)
.String(ss => ss
.Name("st")
.Analyzer("stemmerWordAnalyzer")
)
.String(ss => ss
.Name("raw")
.NotAnalyzed()
)
)
)
)
)
)
);
thanks Russ. i did some experimentation and was able to find the solution to my indexing just before you posted it. glad to know i did it correctly, though it did take an awful lot of experimentation.
glad to hear you're working on some real world examples and how-to type documentation. i know the community would appreciate it.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.