1 # ====================================================================
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 # ====================================================================
18 class Test_Bug1842(unittest.TestCase):
22 self.analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
23 self.d1 = RAMDirectory()
25 w1 = IndexWriter(self.d1, self.analyzer, True,
26 IndexWriter.MaxFieldLength.LIMITED)
28 doc1.add(Field("all", "blah blah blah Gesundheit",
29 Field.Store.NO, Field.Index.ANALYZED,
30 Field.TermVector.YES))
31 doc1.add(Field('id', '1',
32 Field.Store.YES, Field.Index.NOT_ANALYZED))
40 def test_bug1842(self):
42 reader = IndexReader.open(self.d1, True)
43 searcher = IndexSearcher(self.d1, True)
44 q = TermQuery(Term("id", '1'))
45 topDocs = searcher.search(q, 50)
46 freqvec = reader.getTermFreqVector(topDocs.scoreDocs[0].doc, "all")
47 terms = list(freqvec.getTerms())
49 self.assert_(terms == ['blah', 'gesundheit'])
51 freqs = freqvec.getTermFrequencies()
52 self.assert_(freqs == [3, 1])
54 if __name__ == '__main__':