2

I am using elasticsearc 2.3.3 and Nest 2.3.2, I need to create index. Need to map the properties with attributes added in the class file.

public class IndexDocument
{
    [Number(Store = true)]
    public long Id { get; set; }
    [String(Store = true, Index = FieldIndexOption.Analyzed, TermVector = TermVectorOption.WithPositionsOffsets)]
    public string Title { get; set; }
    public Attachment File { get; set; }
    [String(Store = true, Index = FieldIndexOption.Analyzed)]
    public string DocumentType { get; set; }
    [String(Store = true, Index = FieldIndexOption.NotAnalyzed)]
    public string DocLocation { get; set; }
    [String(Store = true, Index = FieldIndexOption.Analyzed)]
    public DateTime LastModifiedDate { get; set; }

}

public class Attachment
{
    public Attachment()
    {

    }
    [String(Name = "_content_length", Store = true, Index = FieldIndexOption.Analyzed)]
    public long ContentLength { get; set; }
    [String(Store = true, Index = FieldIndexOption.Analyzed, TermVector = TermVectorOption.WithPositionsOffsets, Name = "_content")]
    public string Content { get; set; }

}

Also I would like to add a completion suggest to the File field. I am new in this elastic search. Can anyone please help?

I have created my attachment index as below. How to append completion suggest and stemmer code with this?

this.client.CreateIndex("mydocs", c => c.Mappings(mp => mp.Map<IndexDocument>
                (m => m.Properties(ps => ps.Attachment
                        (a => a.Name(o => o.File)
                               .TitleField(t => t.Name(x => x.Title).TermVector(TermVectorOption.WithPositionsOffsets))
                               )))));
Ajoe
  • 1,397
  • 4
  • 19
  • 48
  • How is `Attachment` mapped? As `object`, as `attachment`? – Russ Cam Jun 13 '16 at 23:39
  • @RussCam This is my create index code. this.client.CreateIndex("mydocs", c => c.Mappings(mp => mp.Map (m => m.Properties(ps => ps.Attachment (a => a.Name(o => o.File) .TitleField(t => t.Name(x => x.Title).TermVector(TermVectorOption.WithPositionsOffsets)) ))))); – Ajoe Jun 14 '16 at 03:23
  • @RussCam : Even I'm looking out for this. **1.** How can I add the completion suggester to an attachement(on fields content and title)? **2.** And also can we use multiple analyzers on the same field? because I'm already using english analyzer on my content so that it will look for all the possibilities(like if i search for property, it will check for properties etc ) of the search term and then generate results. I want to add auto complete alongside english analyzer. Is it possible to do so?? TIA – ASN Jun 22 '16 at 05:46
  • @ASN please either add your questions as new questions here on StackOverflow or on https://discuss.elastic.co/ – Russ Cam Jun 22 '16 at 05:58
  • @RussCam ok sure. I just thought it is similar to this question so asked here. Anyways will add a new question on SO. Thanks. – ASN Jun 22 '16 at 06:08
  • @AjA Did you manage to find a solution to this? Adding a completion suggester when indexing the document? – Christer Nordvik Oct 10 '16 at 19:20

0 Answers0