Exemple #1
0
        /// <summary>
        /// Private function to insert an array of words into the base
        /// </summary>
        /// <param name="text">words separated in an array form</param>
        /// <param name="isUserEntry">if it's user entry, the weight will be additionally incremented (more relevant)</param>
        private static void indexInThread(string[] text, bool isUserEntry)
        {
            int    numberOfWordsIndexed = 0;
            string InsertedWord         = "";

            foreach (string word in text)
            {
                numberOfWordsIndexed++;

                if (word.Length > 3)
                {
                    string finalWord = RemoveDiacritics(word);
                    InsertedWord = finalWord.ToLower();
                    overWeight   = luceneSearch.AddUpdateLuceneIndex(finalWord, isUserEntry);

                    if (overWeight != 0 && !_isNormalizing)
                    {
                        _isNormalizing = true;
                        IEnumerable <DataType> wordsToBeCopied = luceneSearch.GetAllIndexRecords();
                        Thread normalizeThread = new Thread(() => Normalize(wordsToBeCopied));
                        normalizeThread.Start();
                    }
                }
            }
        }
Exemple #2
0
        private static void updateInThread(List <DataType> data_list)
        {
            _isUpdating = true;
            foreach (DataType data in data_list)
            {
                if (data.Word.Length > 3)
                {
                    string finalWord = RemoveDiacritics(data.Word);
                    overWeight = luceneSearch.AddUpdateLuceneIndex(finalWord, data.Weight);

                    if (overWeight != 0 && !_isNormalizing)
                    {
                        _isNormalizing = true;
                        IEnumerable <DataType> wordsToBeCopied = luceneSearch.GetAllIndexRecords();
                        Thread normalizeThread = new Thread(() => Normalize(wordsToBeCopied));
                        normalizeThread.Start();
                    }
                }
            }
            _isUpdating = false;
            saveInDisk();
        }