static void Main(string[] args) { //setup ES connections, change as you see fit var settings = new ConnectionSettings(new Uri("http://localhost:9200")).DefaultIndex("emailfrominstagram"); ElasticSearch = new ElasticClient(settings); settings = new ConnectionSettings(new Uri("http://localhost:9200")).DefaultIndex("emailfrominstagramtargets"); ElasticSearchTarget = new ElasticClient(settings); //lets start with #bnw shall we TagQueue.Enqueue("bnw"); TagQueue.Enqueue("bnw_society"); TagQueue.Enqueue("photooftheday"); TagQueue.Enqueue("instamood"); TagQueue.Enqueue("instagood"); TagQueue.Enqueue("mood"); TagQueue.Enqueue("style"); TagQueue.Enqueue("loveit"); TagQueue.Enqueue("dayshots"); TagQueue.Enqueue("artwork"); TagQueue.Enqueue("naturelover"); TagQueue.Enqueue("detail"); TagQueue.Enqueue("igmasters"); TagQueue.Enqueue("igmood"); TagQueue.Enqueue("instamood"); TagQueue.Enqueue("instatravel"); TagQueue.Enqueue("moodstagram"); TagQueue.Enqueue("picoftheday"); Console.WriteLine("STARTING..."); try { //start up threads List <Thread> threads = new List <Thread>(); for (int i = 0; i < 4; i++) { Thread t = new Thread(() => Work(i)); t.Start(); threads.Add(t); } // Await threads foreach (Thread thread in threads) { thread.Join(); } } catch (Exception ex) { Console.WriteLine("ERROR, " + ex); } }
//find tags to look at static void ExtractTagTargets(string input) { //parse for our finders input = input.Replace("\\n", " "); input = input.Replace("\n", " "); Regex tagRegex = new Regex(@"(?<=#)\w+", RegexOptions.IgnoreCase); MatchCollection tagMatches = tagRegex.Matches(input); if (TagQueue != null && TagQueue.Count < 1000) { foreach (Match foundTag in tagMatches) { lock (TagQueue) { if (!TagQueue.Contains(foundTag.ToString())) { TagQueue.Enqueue(foundTag.ToString()); } } } } }