Reputation: 16066
I'm creating an index and also adding a mapping with the indexDescriptor, I have a couple of doubts regarding to the mapping process:
I'm just asking these questions because I'm new using NEST and it seems like the current documentation is outdated
How I'm creating the index:
CreateIndex(IndexName, descriptor => descriptor.AddMapping<CandidateTextInfo>(
m => m.MapFromAttributes().
BoostField(c=>c.SetName(d=>d.Headline)).NumericDetection()));
public class CandidateTextInfo
{
public string ProfilePicture { get; set; }
public ObjectId UserId { get; set; } //field to ignore on mapping
public string Name { get; set; }
public string Headline { get; set; }
public Gender Gender { get; set; }
public byte Rating { get; set; }
public bool IsCompany { get; set; }
public string[] Tags { get; set; }
public string[] Categories { get; set; }
public string ExecutiveSummary { get; set; }
public HourlyRate HourlyRate { get; set; }
}
Upvotes: 1
Views: 3294
Reputation: 22555
First off the documentation nest.azurewebsites.com is current and applies to the latest release of NEST 1.0.0-Beta1 and Elasticsearch.Net. Please ensure you are using this latest version and reference the blog post about it: introducing elasticsearch.net and nest 1.0.0-beta1 for more details.
You can exclude a property in your POCO from being indexed by using the .Enabled()
setting in the Fluent Mapping. Or alternately you can use the OptOut
setting in the ElasticProperty Attribute. (however, I noticed you are staying away from the ElasticProperty attributes).
Please have a look at FluentMappingFullExampleTests.cs in the Nest source for reference on all of the Fluent Mapping settings/options. This includes boosting and the boostField.
Yes, the IndexDescriptor is one option for mapping the class fields. See the Create Index Reference, specifically the section on Create an index with settings and mappings in one go fluently. Alternately, you can use the Put Mapping Api to apply your mapping to the index. Either approach is valid, I personally prefer to apply mappings at index creation time.
Hope this helps.
Upvotes: 2