firestorm.indexField() check for includeTermVectors moved out of loop
This commit is contained in:
parent
45e9eaaacb
commit
5b2bc1c20f
|
@ -96,26 +96,28 @@ func (f *Firestorm) Analyze(d *document.Document) *index.AnalysisResult {
|
||||||
|
|
||||||
func (f *Firestorm) indexField(docID []byte, docNum uint64, includeTermVectors bool, fieldIndex uint16, fieldLength int, tokenFreqs analysis.TokenFrequencies) []index.IndexRow {
|
func (f *Firestorm) indexField(docID []byte, docNum uint64, includeTermVectors bool, fieldIndex uint16, fieldLength int, tokenFreqs analysis.TokenFrequencies) []index.IndexRow {
|
||||||
|
|
||||||
rows := make([]index.IndexRow, 0, len(tokenFreqs))
|
|
||||||
tfrs := make([]TermFreqRow, len(tokenFreqs))
|
tfrs := make([]TermFreqRow, len(tokenFreqs))
|
||||||
|
|
||||||
fieldNorm := float32(1.0 / math.Sqrt(float64(fieldLength)))
|
fieldNorm := float32(1.0 / math.Sqrt(float64(fieldLength)))
|
||||||
|
|
||||||
i := 0
|
if !includeTermVectors {
|
||||||
for _, tf := range tokenFreqs {
|
rows := make([]index.IndexRow, len(tokenFreqs))
|
||||||
var termFreqRow *TermFreqRow
|
i := 0
|
||||||
if includeTermVectors {
|
for _, tf := range tokenFreqs {
|
||||||
tv, newFieldRows := f.termVectorsFromTokenFreq(fieldIndex, tf)
|
rows[i] = InitTermFreqRow(&tfrs[i], fieldIndex, tf.Term, docID, docNum, uint64(tf.Frequency()), fieldNorm, nil)
|
||||||
rows = append(rows, newFieldRows...)
|
i++
|
||||||
termFreqRow = InitTermFreqRow(&tfrs[i], fieldIndex, tf.Term, docID, docNum, uint64(tf.Frequency()), fieldNorm, tv)
|
|
||||||
} else {
|
|
||||||
termFreqRow = InitTermFreqRow(&tfrs[i], fieldIndex, tf.Term, docID, docNum, uint64(tf.Frequency()), fieldNorm, nil)
|
|
||||||
}
|
}
|
||||||
|
return rows
|
||||||
rows = append(rows, termFreqRow)
|
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rows := make([]index.IndexRow, 0, len(tokenFreqs))
|
||||||
|
i := 0
|
||||||
|
for _, tf := range tokenFreqs {
|
||||||
|
tv, newFieldRows := f.termVectorsFromTokenFreq(fieldIndex, tf)
|
||||||
|
rows = append(rows, newFieldRows...)
|
||||||
|
rows = append(rows, InitTermFreqRow(&tfrs[i], fieldIndex, tf.Term, docID, docNum, uint64(tf.Frequency()), fieldNorm, tv))
|
||||||
|
i++
|
||||||
|
}
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user