coady  committed c0c4e93

Document boosting deprecated.

  • Participants
  • Parent commits b82e0e4

Comments (0)

Files changed (2)

File lupyne/engine/

         :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/

         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')
         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
-            indexer.add(doc, boost=('article' in doc) + 1.0)
+            indexer.add(doc)
         searcher = engine.IndexSearcher.load(self.tempdir)
         engine.IndexSearcher.load( # ensure directory isn't closed
         assert hit['article'] == 'Preamble'
         assert sorted(hit.dict()) == ['__id__', '__score__', 'article']
         hits ='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)