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_Bug1763(unittest.TestCase):
22 self.analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
23 self.d1 = RAMDirectory()
24 self.d2 = RAMDirectory()
26 w1, w2 = [IndexWriter(d, self.analyzer, True,
27 IndexWriter.MaxFieldLength.LIMITED)
28 for d in [self.d1, self.d2]]
31 doc1.add(Field("all", "blah blah double blah Gesundheit",
32 Field.Store.NO, Field.Index.ANALYZED))
33 doc1.add(Field('id', '1', Field.Store.YES, Field.Index.NO))
34 doc2.add(Field("all", "a quick brown test ran over the lazy data",
35 Field.Store.NO, Field.Index.ANALYZED))
36 doc2.add(Field('id', '2',
37 Field.Store.YES, Field.Index.NO))
47 def test_bug1763(self):
49 w1 = IndexWriter(self.d1, self.analyzer, True,
50 IndexWriter.MaxFieldLength.LIMITED)
51 w1.addIndexes([IndexReader.open(self.d2, True)])
55 searcher = IndexSearcher(self.d1, True)
56 q = QueryParser(Version.LUCENE_CURRENT, 'all',
57 self.analyzer).parse('brown')
58 topDocs = searcher.search(q, 50)
59 self.assertEqual(searcher.doc(topDocs.scoreDocs[0].doc).get('id'), '2')
62 if __name__ == '__main__':