문제

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


    }
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top