-
Notifications
You must be signed in to change notification settings - Fork 34
/
SearchItemDocumentBase.cs
40 lines (33 loc) · 1.11 KB
/
SearchItemDocumentBase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Nest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Elastic.Example.Services.Mappings
{
public class SearchItemDocumentBase
{
[Keyword(Name = nameof(Id))]
public string Id { get; set; }
[Text(Analyzer = "autocomplete", Name = nameof(Title))]
public string Title { get; set; }
[Text(Analyzer = "html_stripper", Name = nameof(Summary))]
public string Summary { get; set; }
[Number(Name = nameof(Rating))]
public double Rating { get; set; }
[Text(Analyzer = "keywords_wo_stopwords", Name = nameof(Keywords))]
public string Keywords { get; set; }
public SearchItemDocumentBase()
{
Rating = 0.7;
}
internal virtual void PostProcess(HighlightFieldDictionary highlights)
{
if (highlights?.Any(h => h.Key == nameof(Summary)) == true)
{
Summary = string.Join("...", highlights.First(p => p.Key == nameof(Summary)).Value.Highlights);
}
}
}
}