Commits

coady  committed c0c4e93

Document boosting deprecated.

  • Participants
  • Parent commits b82e0e4

Comments (0)

Files changed (2)

File lupyne/engine/indexers.py

         :param params: store,index,termvector options compatible with `Field`_
         """
         self.fields[name] = cls(name, **params)
-    def document(self, document=(), boost=1.0, **terms):
+    def document(self, document=(), boost=None, **terms):
         "Return lucene Document from mapping of field names to one or multiple values."
         doc = lucene.Document()
-        doc.boost = boost
+        if boost is not None:
+            warnings.warn('Document boosting has been removed from lucene 4; set Field boosts instead.', DeprecationWarning)
+            doc.boost = boost
         for name, values in dict(document, **terms).items():
             if isinstance(values, Atomic):
                 values = values,

File test/local.py

         indexer.commit()
         assert 0 not in indexer and len(indexer) == 0 and sum(indexer.segments.values()) == 0
         indexer.add(tag='test', name='old')
-        indexer.update('tag', boost=2.0, tag='test')
+        with assertWarns(DeprecationWarning):
+            indexer.update('tag', boost=2.0, tag='test')
         indexer.commit()
         assert [indexer[id].dict() for id in indexer] == [{'tag': 'test'}]
         indexer.update('tag', 'test', {'name': 'new'})
         for name, params in fixture.constitution.fields.items():
             indexer.set(name, **params)
         for doc in fixture.constitution.docs():
-            indexer.add(doc, boost=('article' in doc) + 1.0)
+            indexer.add(doc)
         indexer.commit()
         searcher = engine.IndexSearcher.load(self.tempdir)
         engine.IndexSearcher.load(searcher.directory) # ensure directory isn't closed
         assert hit['article'] == 'Preamble'
         assert sorted(hit.dict()) == ['__id__', '__score__', 'article']
         hits = indexer.search('people', field='text')
-        assert hits[0]['article'] == 'Preamble'
+        assert 'Preamble' in (hit.get('article') for hit in hits)
         assert len(hits) == hits.count == 8
         assert set(map(type, hits.ids)) == set([int]) and set(map(type, hits.scores)) == set([float])
         assert hits.maxscore == max(hits.scores)