Example #1
0
def add_post_index():
	posts = Post.objects.all()
	for post in posts:
		try:
			si = SearchIndex.objects.get(object_id=post.id,object_type='post')
			si.title = post.title
			si.content = post.body
		except:
			si = SearchIndex(
				title = post.title,
				content = post.body,
				object_id = post.id,
				object_type = 'post'
			)
		si.object_image_url = post.author.get_api_profile_image_url()
		si.save()
	print "Indexed ",posts.count()," posts."
Example #2
0
def add_profile_index():
	users = GolfUser.objects.all()
	for user in users:
		try:
			si = SearchIndex.objects.get(object_id=user.id,object_type='profile')
			si.title = user.get_full_name()
			si.content = user.email
			si.private = user.is_private
		except:
			si = SearchIndex(
				title = user.get_full_name(),
				content = user.email,
				object_id = user.id,
				object_type = 'profile',
				private = user.is_private,
			)
		si.object_image_url = user.get_api_profile_image_url() 
		si.save()
	print "Indexed ",users.count()," users."