Moving indexing code out of web service.