public void ExtractRequestHandler() { var pathForFile = DirectoryUtility.GetDirectoryTestFile(); using (var file = File.OpenRead(pathForFile)) { var response = solr.Extract(new ExtractParameters(file, "abcd") { ExtractOnly = true, ExtractFormat = ExtractFormat.Text, }); Assert.That(response.Content, Does.Contain("Your PDF viewing software works!")); } }
public static string extract_file_content(Guid applicationId, DocFileInfo file) { ISolrOperations <SolrDoc> solr = get_solr_operator(); using (Stream content = new MemoryStream(file.toByteArray(applicationId))) { ExtractResponse response = solr.Extract(new ExtractParameters(content, PublicMethods.get_random_number().ToString(), PublicMethods.random_string(10)) { ExtractOnly = true, ExtractFormat = ExtractFormat.Text }); return(response.Content); } }
public void IndexRichText(string path, string id, ICollection <string> acl, ICollection <string> languages, DateTime startPublish, DateTime endPublish, string cmsContentId = null) { Path.GetFileName(path); try { ISolrOperations <CmsSearchResultItem> instance = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItem> >(); using (Stream file = this.cmsIndexer.GetFile(path)) { ExtractParameters parameters = new ExtractParameters(file, "media" + id, path) { ExtractFormat = ExtractFormat.Text, ExtractOnly = false, Fields = (IEnumerable <ExtractField>) new ExtractField[3] { new ExtractField("doctypes", "media"), new ExtractField("start_publish", startPublish.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")), new ExtractField("end_publish", endPublish.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")) } }; List <ExtractField> list = parameters.Fields.ToList <ExtractField>(); if (!string.IsNullOrEmpty(cmsContentId)) { list.Add(new ExtractField("content_ref", cmsContentId)); } foreach (string str in (IEnumerable <string>)acl) { list.Add(new ExtractField("acl", str)); } foreach (string language in (IEnumerable <string>)languages) { list.Add(new ExtractField("lang", language)); } parameters.Fields = (IEnumerable <ExtractField>)list; instance.Extract(parameters); } instance.Commit(); } catch (Exception ex) { this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, string.Format("Error indexing data from richtext document {0} with id {1}", (object)path, (object)id), ex); } }
private static void AddFileToIndex(ISolrOperations <FileIndex> solr, string file) { Console.WriteLine($"Adding to index: {file}"); using (FileStream fileStream = File.OpenRead(file)) { solr.Extract( new ExtractParameters(fileStream, Path.GetFileName(file)) { ExtractFormat = ExtractFormat.Text, ExtractOnly = false, Fields = new List <ExtractField> { new ExtractField(FileIndex.Keys.FilePath, file), new ExtractField(FileIndex.Keys.Delete, "false") } }); solr.Commit(); } }