private static void ProcessDirs(string folderPath, string searchPattern)
        {
            try
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow  = false;
                startInfo.UseShellExecute = false;
                startInfo.FileName        = @"C:\temp\curl-7.48.0-win64-mingw\bin\curl.exe";
                startInfo.WindowStyle     = ProcessWindowStyle.Hidden;

                foreach (string file in Directory.GetFiles(folderPath, searchPattern))
                {
                    System.IO.File.AppendAllText(@"c:\temp\solr.log", file + "\n");
                    StringBuilder myFileBuilder = new StringBuilder(file);
                    string        myFile        = myFileBuilder.Replace(@"\", @"/").ToString();

                    string filePath = System.Web.HttpUtility.UrlEncode(file);
                    //string fileName = System.Web.HttpUtility.UrlEncode(System.IO.Path.GetFileName(file));

                    // http://localhost:8983/solr/gettingStarted/update/extract?literal.id=25&commit=true" -F "myfile=@/Users/jllorin/Documents/oaktown.pdf
                    startInfo.Arguments = $"\"http://*****:*****@{myFile}\"";
                    try
                    {
                        // Start the process with the info we specified.
                        // Call WaitForExit and then the using statement will close.
                        using (Process exeProcess = Process.Start(startInfo))
                        {
                            exeProcess.WaitForExit();
                        }
                    }
                    catch (Exception ex)
                    {
                        Utilities.SolrException.WriteError(ex);
                    }
                }

                foreach (string dir in Directory.GetDirectories(folderPath))
                {
                    SolrOperation.ProcessDirs(dir, searchPattern);
                }
            }
            catch (Exception ex)
            {
                Solr.Utilities.SolrException.WriteError(ex);
            }
        }
Ejemplo n.º 2
0
 private bool DeleteFieldInLucene()
 {
     try
     {
         var    requestString = $"http://*****:*****@"{{
          delete-field: {{
             name: '{0}'
          }}
         }}", this.Name);
         SolrOperation.LucenePostJson(requestString, json);
     }
     catch (Exception ex)
     {
         Solr.Utilities.SolrException.WriteError(ex);
     }
     return(false);
 }
Ejemplo n.º 3
0
 public static string Select(string query, string rows, string sort, string start, string fields)
 {
     try
     {
         // Create a request for the URL.
         string queryString = $"&q={System.Web.HttpUtility.UrlEncode(query)}";
         rows   = string.IsNullOrEmpty(rows) ? "" : $"&rows={rows}";
         sort   = string.IsNullOrEmpty(sort) ? "" : $"&sort={sort}";
         start  = string.IsNullOrEmpty(start) ? "" : $"&start={start}";
         fields = string.IsNullOrEmpty(fields) ? "" : $"&fl={fields}";
         var requestString = $"http://localhost:8983/solr/gettingStarted/select?indent=on{queryString}{rows}{sort}{start}{fields}&wt=json";
         return(SolrOperation.LuceneRequest(requestString));
     }
     catch (Exception ex)
     {
         Solr.Utilities.SolrException.WriteError(ex);
     }
     return(null);
 }
Ejemplo n.º 4
0
 public bool AddFieldInLucene()
 {
     try
     {
         var    requestString = $"http://*****:*****@"{{
          add-field: {{
             name: '{0}',
             type: '{1}',
             stored: '{2}',
             indexed: '{3}',
             default: '{4}' 
          }}
         }}", this.Name, this.Type, this.Stored == "Yes" ? "true" : "false", this.Indexed == "Yes" ? "true" : "false", this.DefaultValue);
         SolrOperation.LucenePostJson(requestString, json);
     }
     catch (Exception ex)
     {
         Solr.Utilities.SolrException.WriteError(ex);
     }
     return(false);
 }