Commits

Jason R. Coombs  committed 5f616b3

Fixed parts of the implementation. Now indexed details (posts) are being stored in the database.

  • Participants
  • Parent commits d6ce23f

Comments (0)

Files changed (2)

File tests/test_simple.py

 def setup_module(mod):
 	# for now, drop previous results when running tests
 	pymongo.Connection().thwump.index.drop()
+	pymongo.Connection().thwump.index.posts.drop()
 
 def test_quick_example():
 	"""
 	schema = fields.Schema(
 		title=fields.TEXT(stored=True),
 		path=fields.ID(stored=True),
-		context=fields.TEXT,
+		content=fields.TEXT,
 	)
 	ix = Index(schema=schema)
 	writer = ix.writer()

File thwump/writing.py

 
 			if field.indexed:
 				# Get the index details for the field
-				details = field.index(value)
-				if field.scoreable:
-					doc[field_name] = dict(
-						length = sum(freq for tbytes, freq, weight, vbytes
-							in details),
-						)
+				scorable = field.scorable
 				# store the details
-				for text, freq, weight, vector in details:
+				for text, freq, weight, vector in field.index(value):
+					if scorable:
+						doc_field = doc.setdefault(field_name, {})
+						doc_field['length'] = doc_field.get('length', 0) + freq
 					self.index.collection.posts.insert(dict(
 						doc_id = doc_id,
 						field_name=field_name,