simplify FieldMapping.analyzerForField()
I stumbled onto that while trying to understand how analyzers are resolved. The new code looks simpler to me and removes useless calls to DocumentMapping.defaultAnalyzerName() when an analyzer is set at FieldMapping level. The slight change to TestStoredFieldPreserved avoids a stacktrace when the test fails.
This commit is contained in:
parent
21473509b2
commit
498e4a0de7
|
@ -433,7 +433,7 @@ func TestStoredFieldPreserved(t *testing.T) {
|
|||
}
|
||||
|
||||
if len(res.Hits) != 1 {
|
||||
t.Errorf("expected 1 hit, got %d", len(res.Hits))
|
||||
t.Fatalf("expected 1 hit, got %d", len(res.Hits))
|
||||
}
|
||||
|
||||
if res.Hits[0].Fields["name"] != "Marty" {
|
||||
|
|
|
@ -132,12 +132,12 @@ func (fm *FieldMapping) processTime(propertyValueTime time.Time, pathString stri
|
|||
}
|
||||
|
||||
func (fm *FieldMapping) analyzerForField(path []string, context *walkContext) *analysis.Analyzer {
|
||||
analyzerName := context.dm.defaultAnalyzerName(path)
|
||||
analyzerName := fm.Analyzer
|
||||
if analyzerName == "" {
|
||||
analyzerName = context.im.DefaultAnalyzer
|
||||
}
|
||||
if fm.Analyzer != "" {
|
||||
analyzerName = fm.Analyzer
|
||||
analyzerName = context.dm.defaultAnalyzerName(path)
|
||||
if analyzerName == "" {
|
||||
analyzerName = context.im.DefaultAnalyzer
|
||||
}
|
||||
}
|
||||
return context.im.analyzerNamed(analyzerName)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue