private void Update(Document document, Dictionary<string, Dictionary<int, List<int>>> index, Dictionary<int, string> docs)
        {
            var doc = docs.Where(x => x.Value == document.Url)
                          .Select(x => new { Key = x.Key, Value = x.Value })
                          .FirstOrDefault();

            var id = (doc != null) ? doc.Key : ((docs != null && docs.Count > 0) ? docs.Max(x => x.Key) : 0);

            // Add this document's URL to the lookup list if it isn't already there
            if(doc == null)
				docs.Add(++id, document.Url);

            var words = _contentProcessor.Tokenise(document.Content);

            for (var i = 0; i < words.Count; i++)
            {
                var word = words[i];

                // If the index doesn't already contain an entry 
                // for this word, add one
                if (!index.ContainsKey(word))
                    index.Add(word, new Dictionary<int, List<int>>());

                // If the entry for this word doesn't contain an entry 
                // for this document's URL, add one
                if (!index[word].ContainsKey(id))
                    index[word].Add(id, new List<int>());

                // Add the index of this word in the document to 
                // the list for this document/word
                index[word][id].Add(i);
            }
        }
        public void AddDocument(Document document)
        {
            var index = LoadIndex();
            var docs = LoadDocs();

            Update(document, index, docs);

            SaveIndex(index, docs);

            DocumentCount ++;
        }