private static void SetProgrammingFilestoDeleteTrue(ISolrOperations <FileIndex> solr) { var solrQueryResults = solr.Query(new SolrQuery("matched_functions:\"Programming Files\"")); foreach (var solrQueryResult in solrQueryResults) { var atomicUpdateSpecs = new List <AtomicUpdateSpec> { new AtomicUpdateSpec(FileIndex.Keys.Delete, AtomicUpdateType.Set, "true") }; solr.AtomicUpdate(solrQueryResult, atomicUpdateSpecs); } solr.Commit(); }
private static void UpdateData(ISolrOperations <FileIndex> solr) { Console.WriteLine("Updating Index"); var dictionary = GetDictionary(); var solrQueryResults = solr.Query(new SolrQuery("*")); foreach (var key in dictionary.Keys) { foreach (var solrQueryResult in solrQueryResults) { var atomicUpdateSpecs = new List <AtomicUpdateSpec>(); if (dictionary[key].IsMatch(solrQueryResult.FilePath)) { if (!solrQueryResult.MatchedFunctions.Contains(key)) { atomicUpdateSpecs.Add(new AtomicUpdateSpec(FileIndex.Keys.MatchedFunctions, AtomicUpdateType.Add, new[] { key })); atomicUpdateSpecs.Add(new AtomicUpdateSpec(FileIndex.Keys.UnmatchedFunctions, AtomicUpdateType.Remove, new[] { key })); } } else { if (!solrQueryResult.UnmatchedFunctions.Contains(key)) { atomicUpdateSpecs.Add(new AtomicUpdateSpec(FileIndex.Keys.UnmatchedFunctions, AtomicUpdateType.Add, new[] { key })); atomicUpdateSpecs.Add(new AtomicUpdateSpec(FileIndex.Keys.MatchedFunctions, AtomicUpdateType.Remove, new[] { key })); } } // don't do the update if there is nothing to do as it will // wipe out all of the data if (atomicUpdateSpecs.Any()) { solr.AtomicUpdate(solrQueryResult, atomicUpdateSpecs); } } solr.Commit(); } }