PyLucene 3.4.0-1 import
[pylucene.git] / test / test_bug1564.py
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
5 #
6 #       http://www.apache.org/licenses/LICENSE-2.0
7 #
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 # ====================================================================
14
15 import unittest
16 from lucene import *
17
18 class Test_Bug1564(unittest.TestCase):
19
20     def setUp(self):
21
22         self.analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
23         self.store = RAMDirectory()
24
25         writer = IndexWriter(self.store, self.analyzer, True,
26                              IndexWriter.MaxFieldLength.LIMITED)
27         doc = Document()
28         doc.add(Field('all', u'windowpane beplaster rapacious \
29         catatonia gauntlet wynn depressible swede pick dressmake supreme \
30         jeremy plumb theoretic bureaucracy causation chartres equipoise \
31         dispersible careen heard',
32                       Field.Store.NO, Field.Index.ANALYZED))
33         doc.add(Field('id', '1', Field.Store.YES, Field.Index.NO))
34         writer.addDocument(doc)
35         writer.optimize()
36         writer.close()
37
38     def tearDown(self):
39         pass
40
41     def test_bug1564(self):
42
43         searcher = IndexSearcher(self.store, True)
44         query = QueryParser(Version.LUCENE_CURRENT, 'all',
45                             self.analyzer).parse('supreme')
46         topDocs = searcher.search(query, 50)
47         self.assertEqual(topDocs.totalHits, 1)
48
49
50 if __name__ == '__main__':
51     import lucene
52     lucene.initVM()
53     unittest.main()