static void TestIndexSearch() { var image = new ImagesIndexDoc(); image.DateAdded = DateTime.Now; image.Id = Guid.NewGuid().ToString(); image.SourceUrl = "http://i.ndtvimg.com/i/2016-02/arun-jaitley-budget_650x400_51456737432.jpg"; image.Tags = new string[] { "Jaitley" }; image.Url = "https://storage.googleapis.com/www.archishainnovators.com/images/image.jpeg"; var imageIndex = IndexFactory.ImagesIndex; imageIndex.UploadDocument(image).Wait(); }
public async Task <bool> PostArticle([FromBody] UnpublishedPost post) { DocumentIndexResult uploadedDoc; try { if (post.ShouldSkip) { SkippedUrlsIndexDoc skippedDoc = post.ToSkippedUrlsIndexDoc(); uploadedDoc = await _skippedUrlsIndex.UploadDocument(skippedDoc); return(uploadedDoc.Results.First().Succeeded); } FeedsIndexDoc doc = post.ToFeedsIndexDoc(); // Upload image to local resource var filename = string.Format("{0}.jpeg", doc.Id); var uploadSucc = await _ds.UploadImageAsync(filename, doc.ImageUrl); // If tagged, upload to image db bool imageUploaded = true; var uploadedUrl = string.Format("https://storage.googleapis.com/www.archishainnovators.com/images/{0}", filename); if (post.Image.Tags.Any()) { ImagesIndexDoc imageDoc = new ImagesIndexDoc { Id = doc.Id, DateAdded = DateTime.Now, SourceUrl = doc.ImageUrl, Url = uploadedUrl, Tags = post.Image.Tags }; var uploadResult = await _imagesIndex.UploadDocument(imageDoc); imageUploaded = uploadResult.Results.First().Succeeded; } doc.ImageUrl = uploadedUrl; // Upload post uploadedDoc = await _feedsIndex.UploadDocument(doc); return(uploadedDoc.Results.First().Succeeded&& imageUploaded); } catch (Exception e) { throw e; } }