Skip to content

Commit

Permalink
refactor: or-1972 extract methods for index creation
Browse files Browse the repository at this point in the history
  • Loading branch information
koenmetsu committed Nov 16, 2023
1 parent e6aac38 commit 78583ab
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ public static void CreateDuplicateDetectionIndex(this IndicesNamespace indicesNa
selector: c => c
.Settings(s => s
.Analysis(a => a
.Analyzers(ad => ad
.Custom(DuplicateDetectionDocumentMapping.DuplicateAnalyzer, selector: ca
=> ca
.Tokenizer("standard")
.Filters("lowercase", "asciifolding", "dutch_stop")
))
.TokenFilters(tf => tf
.Stop(name: "dutch_stop", selector: st => st
.StopWords("_dutch_") // Or provide your custom list
)
)
))
.Analyzers(AddDuplicateDetectionAnalyzer)
.TokenFilters(AddDutchStopWordsFilter)))
.Map<DuplicateDetectionDocument>(DuplicateDetectionDocumentMapping.Get));

private static TokenFiltersDescriptor AddDutchStopWordsFilter(TokenFiltersDescriptor tf)
=> tf.Stop(name: "dutch_stop", selector: st => st
.StopWords("_dutch_") // Or provide your custom list
);

private static AnalyzersDescriptor AddDuplicateDetectionAnalyzer(AnalyzersDescriptor ad)
=> ad.Custom(DuplicateDetectionDocumentMapping.DuplicateAnalyzer,
selector: ca
=> ca
.Tokenizer("standard")
.Filters("lowercase", "asciifolding", "dutch_stop")
);
}

0 comments on commit 78583ab

Please sign in to comment.