예제 #1
0
        private static void _remove_docs(Guid applicationId, List <SearchDoc> docs)
        {
            if (RaaiVanSettings.Solr.Enabled)
            {
                SolrAPI.delete(applicationId, docs);
                return;
            }

            try
            {
                //Delete from Hard
                IndexWriter writer = _create_writer(applicationId, false);
                foreach (SearchDoc dc in docs)
                {
                    writer.DeleteDocuments(new Term("ID", dc.ID.ToString()));
                }
                _close_writer(applicationId, ref writer);

                //Delete from Ram
                if (RaaiVanSettings.IndexUpdate.Ram(applicationId))
                {
                    writer = _create_writer(applicationId, true);
                    foreach (SearchDoc dc in (List <SearchDoc>)docs)
                    {
                        writer.DeleteDocuments(new Term("ID", dc.ID.ToString()));
                    }
                    _close_writer(applicationId, ref writer);
                }
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, "RemoveIndexDocuments", ex, ModuleIdentifier.SRCH);
            }
        }
예제 #2
0
        private static void update_index(Guid applicationId, List <SearchDoc> docs)
        {
            if (RaaiVanSettings.Solr.Enabled)
            {
                SolrAPI.add(applicationId, docs);
                return;
            }

            _update_index(applicationId, docs);
        }
예제 #3
0
        private static void search(Guid applicationId, ref List <SearchDoc> retDocs, ref List <SearchDoc> toBeRemoved,
                                   Guid?currentUserId, ref int?lowerBoundary, int count, ref Query query, ref IndexSearcher searcher,
                                   string phrase, List <SearchDocType> docTypes, List <Guid> typeIds, List <string> types, bool additionalId, bool title,
                                   bool description, bool content, bool tags, bool fileContent, bool forceHasContent, bool highlight, ref int totalCount)
        {
            if (!lowerBoundary.HasValue)
            {
                lowerBoundary = 0;
            }

            int newBoundary = lowerBoundary.Value;

            List <SearchDoc> listDocs = new List <SearchDoc>();

            if (RaaiVanSettings.Solr.Enabled)
            {
                listDocs = SolrAPI.search(applicationId, phrase, docTypes, typeIds, types, additionalId, title,
                                          description, tags, content, fileContent, forceHasContent, count, newBoundary, highlight, ref totalCount)
                           .Select(d => SearchDoc.ToSearchDoc(d)).Where(d => d != null).ToList();
            }
            else
            {
                if (query == null || searcher == null)
                {
                    create_lucene_searcher(applicationId, docTypes, typeIds, types, additionalId,
                                           title, description, content, tags, fileContent, forceHasContent, phrase, ref query, ref searcher);

                    if (query == null || searcher == null)
                    {
                        return;
                    }
                }

                listDocs = lucene_search(applicationId, newBoundary, count, ref query, ref searcher,
                                         additionalId, title, description, content, tags, fileContent);
            }

            retDocs.AddRange(process_search_results(applicationId, listDocs, currentUserId, ref toBeRemoved, count));

            newBoundary += listDocs.Count;

            if (lowerBoundary != newBoundary)
            {
                lowerBoundary = newBoundary;
                if (retDocs.Count < count)
                {
                    search(applicationId, ref retDocs, ref toBeRemoved, currentUserId, ref lowerBoundary,
                           count - retDocs.Count, ref query, ref searcher, phrase, docTypes, typeIds, types, additionalId, title,
                           description, content, tags, fileContent, forceHasContent, highlight, ref totalCount);
                }
            }
        }