Skip to content

Commit c336f3d

Browse files
Merge branch 'main' of github.com:minhsangdotcom/elasticsearch-fluent-configuration
2 parents dee89ee + ae3853c commit c336f3d

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

README.md

+78-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
1-
# elasticsearch-fluent-configuration
1+
# Els Fluent configurations
2+
3+
Fluent Configurations for elasticsearch in c#.
4+
5+
**Example**
6+
```csharp
7+
public class AuditLogConfiguration : IElasticsearchDocumentConfigure<AuditLog>
8+
{
9+
public void Configure(ref ElasticsearchConfigBuilder<AuditLog> buider, string? prefix = null)
10+
{
11+
// declare the name of index
12+
buider.ToIndex("audit_log");
13+
14+
// set key
15+
buider.HasKey(key => key.Id);
16+
17+
// add settings
18+
buider.Settings(setting =>
19+
setting.Analysis(x =>
20+
x.Analyzers(an =>
21+
an.Custom(
22+
"myTokenizer",
23+
ca => ca.Filter(["lowercase"]).Tokenizer("myTokenizer")
24+
)
25+
.Custom(
26+
"standardAnalyzer",
27+
ca => ca.Filter(["lowercase"]).Tokenizer("standard")
28+
)
29+
)
30+
.Tokenizers(tz =>
31+
tz.NGram(
32+
"myTokenizer",
33+
config =>
34+
config
35+
.MinGram(3)
36+
.MaxGram(4)
37+
.TokenChars([TokenChar.Digit, TokenChar.Letter])
38+
)
39+
)
40+
)
41+
);
42+
43+
// Map properties Manually
44+
buider.Properties(config =>
45+
config
46+
.Text(
47+
t => t.Id,
48+
config =>
49+
config
50+
.Fields(f =>
51+
f.Keyword("Id")
52+
)
53+
.Analyzer("myTokenizer")
54+
.SearchAnalyzer("standardAnalyzer")
55+
)
56+
.Text(
57+
txt => txt.Entity,
58+
config =>
59+
config
60+
.Fields(f =>
61+
f.Keyword("Entity")
62+
)
63+
.Analyzer("myTokenizer")
64+
.SearchAnalyzer("standardAnalyzer")
65+
)
66+
.ByteNumber(b => b.Type)
67+
.Object(o => o.OldValue!)
68+
.Object(o => o.NewValue!)
69+
.Text(txt => txt.ActionPerformBy!)
70+
.Keyword(d => d.CreatedAt)
71+
);
72+
73+
// Ignore properties
74+
buider.Ignores([x => x.NewValue!, x => x.Type]);
75+
}
76+
}
77+
```
78+
Let check the source code out at [Nuget](https://www.nuget.org/packages/minhsangdotcom.TheTemplate.ElasticsearchFluentConfig)

0 commit comments

Comments
 (0)