1

I'm creating an index and also adding a mapping with the indexDescriptor, I have a couple of doubts regarding to the mapping process:

  1. how can I avoid to index a specific field from a class?
  2. how can I boost and specify the value of the "boostfield" with the fluent interface configuration?
  3. is the IndexDescriptor the correct place to map the class fields without using the ElasticProperty Attribute

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; }


    }

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

5 Comments

thanks!, I just meant updated because if you look at the mapping reference nest.azurewebsites.net/nest/indices/put-mapping.html in the Code based mapping it's explained the usage of TypeMapping which seems to be outdated, but probably the assumption that all the documentation is outdated is wrong, thanks for the answer it's very useful
Thanks for the clarification on the documentation. I agree, there are a few sections of the documentation that are in need of an update and Put Mapping for Code based mapping looks to be one of them.
You guys are totally right some parts of the documentation have not been updated to 1.0 yet, very confusing :/
Gents, anyone know how to do this fluently using .Enabled()? Got an example?
[ElasticProperty(OptOut = true)] above the member I wanted to ignore was exactly what I was looking for!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.