public virtual void SetUp()
 {
     _cut = new TextExtractor();
 }
示例#2
-1
        static void Main(string[] args)
        {
            string currentDir = "";
            if (args.Length == 0)
            {
                currentDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            } else
                currentDir = args[0];
            if (args.Length > 1)
                _IndexName = args[1];
            var files = System.IO.Directory.GetFiles(currentDir);
            _cut = new TextExtractor();
            var es = elastic();
            es.CreateIndex(_IndexName, ind => ind.Index(_IndexName)
                .AddMapping<Article>(t => t.MapFromAttributes()));

            foreach (string file in files)
            {
                try
                {
                    var test = tika(file);
                    var indexresult = es.Index<Article>(test);
                    Console.WriteLine(indexresult.Id);
                }
                catch (Exception e)
                {

                    Console.WriteLine(e.Message);
                    continue;
                }
            }
        }