예제 #1
0
 public void Add(OpenContentInfo data, FieldConfig config)
 {
     if (null == data)
     {
         throw new ArgumentNullException("data");
     }
     Store.Add(JsonMappingUtils.JsonToDocument(data.ModuleId.ToString(), data.ContentId.ToString(), data.CreatedByUserId.ToString(), data.CreatedOnDate, data.JsonAsJToken, data.Json, config));
 }
예제 #2
0
 public void Add(IIndexableItem data, FieldConfig config)
 {
     if (null == data)
     {
         throw new ArgumentNullException("data");
     }
     Store.Add(JsonMappingUtils.JsonToDocument(data.GetScope(), data.GetId(), data.GetCreatedByUserId(), data.GetCreatedOnDate(), data.GetData(), data.GetSource(), config));
 }
예제 #3
0
        /// <summary>
        /// Deletes the matching objects in the IndexWriter.
        /// </summary>
        /// <param name="data"></param>
        public void Delete(IIndexableItem data)
        {
            Requires.NotNull(data);

            var   selection   = new TermQuery(new Term(JsonMappingUtils.FIELD_ID, data.GetId()));
            Query deleteQuery = new FilteredQuery(selection, JsonMappingUtils.GetTypeFilter(data.GetScope()));

            Store.Delete(deleteQuery);
        }
예제 #4
0
        /// <summary>
        /// Deletes the matching objects in the IndexWriter.
        /// </summary>
        /// <param name="data"></param>
        public void Delete(IIndexableItem data)
        {
            if (null == data)
            {
                throw new ArgumentNullException("data");
            }
            var   selection   = new TermQuery(new Term(JsonMappingUtils.FieldId, data.GetId()));
            Query deleteQuery = new FilteredQuery(selection, JsonMappingUtils.GetTypeFilter(data.GetScope()));

            Store.Delete(deleteQuery);
        }
예제 #5
0
 public static TopDocs Search(Searcher searcher, string type, Query query, Query filter, int numResults, Sort sort)
 {
     try
     {
         return(searcher.Search(query, JsonMappingUtils.GetTypeFilter(type, filter), numResults, sort));
     }
     catch (Exception ex)
     {
         App.Services.Logger.Error($"Error while searching {type}, {query}", ex);
         throw;
     }
 }
예제 #6
0
 public static TopDocs Search(this Searcher searcher, string type, Query query, Query filter, int numResults, Sort sort)
 {
     try
     {
         return(searcher.Search(query, JsonMappingUtils.GetTypeFilter(type, filter), numResults, sort));
     }
     catch (Exception ex)
     {
         Log.Logger.ErrorFormat("Error while searching {0}, {1}", type, query.ToString());
         throw ex;
     }
 }
예제 #7
0
        /// <summary>
        /// Deletes the matching objects in the IndexWriter.
        /// </summary>
        /// <param name="data"></param>
        public void Delete(OpenContentInfo data)
        {
            if (null == data)
            {
                throw new ArgumentNullException("data");
            }

            var selection = new TermQuery(new Term(JsonMappingUtils.FieldId, data.ContentId.ToString()));

            Query deleteQuery = new FilteredQuery(selection, JsonMappingUtils.GetTypeFilter(data.ModuleId.ToString()));

            Store.Delete(deleteQuery);
        }
예제 #8
0
        public static Query ParseQuery(string searchQuery, string defaultFieldName)
        {
            var   parser = new QueryParser(Version.LUCENE_30, defaultFieldName, JsonMappingUtils.GetAnalyser());
            Query query;

            try
            {
                if (String.IsNullOrEmpty(searchQuery))
                {
                    query = new MatchAllDocsQuery();
                }
                else
                {
                    query = parser.Parse(searchQuery.Trim());
                }
            }
            catch (ParseException)
            {
                query = parser.Parse(QueryParser.Escape(searchQuery.Trim()));
            }
            return(query);
        }
예제 #9
0
        public static Query ParseQuery(string searchQuery, string defaultFieldName, string CultureCode = "")
        {
            searchQuery = RemoveDiacritics(searchQuery);
            searchQuery = searchQuery.Replace('-', ' '); // concider '-' as a space
            var   parser = new QueryParser(Version.LUCENE_30, defaultFieldName, JsonMappingUtils.GetAnalyser(CultureCode));
            Query query;

            try
            {
                if (string.IsNullOrEmpty(searchQuery))
                {
                    query = _DefaultQuery;
                }
                else
                {
                    query = parser.Parse(searchQuery.Trim());
                }
            }
            catch (ParseException)
            {
                query = searchQuery != null?parser.Parse(QueryParser.Escape(searchQuery.Trim())) : _DefaultQuery;
            }
            return(query);
        }
예제 #10
0
 /// <summary>
 /// Searches for documents mapped from the given type using the specified query and Collector.
 /// </summary>
 /// <param name="searcher">
 /// The Searcher to search on.
 /// </param>
 /// <param name="type">
 /// The type of the object to search documents for.
 /// </param>
 /// <param name="query">
 /// The Query which selects the documents.
 /// </param>
 /// <param name="results">
 /// The Collector to use to gather results.
 /// </param>
 public static void Search(this Searcher searcher, string type, Query query, Collector results)
 {
     searcher.Search(query, JsonMappingUtils.GetTypeFilter(type), results);
 }
예제 #11
0
        public static TopDocs Search(this Searcher searcher, string type, Query query, int numResults, Sort sort)
        {
            var res = searcher.Search(query, JsonMappingUtils.GetTypeFilter(type), numResults, sort);

            return(res);
        }
예제 #12
0
        public void Add(IIndexableItem data, FieldConfig config)
        {
            Requires.NotNull(data);

            Store.Add(JsonMappingUtils.JsonToDocument(data.GetScope(), data.GetId(), data.GetCreatedByUserId(), data.GetCreatedOnDate(), data.GetData(), data.GetSource(), config));
        }
예제 #13
0
        public static TopDocs Search(this Searcher searcher, string type, Query Filter, Query query, int numResults)
        {
            Filter filter = new QueryWrapperFilter(query);

            return(searcher.Search(query, JsonMappingUtils.GetTypeFilter(type, Filter), numResults));
        }
예제 #14
0
 public static TopDocs Search(this Searcher searcher, string type, Query query, int numResults)
 {
     return(searcher.Search(query, JsonMappingUtils.GetTypeFilter(type), numResults));
 }
예제 #15
0
 private LuceneController()
 {
     _serviceInstance = new LuceneService(AppConfig.Instance.LuceneIndexFolder, JsonMappingUtils.GetAnalyser());
 }
예제 #16
0
        private static void DeleteAllOfType(LuceneController lc, string scope)
        {
            var selection = JsonMappingUtils.CreateTypeQuery(scope);

            lc.Store.Delete(selection);
        }
예제 #17
0
        private LuceneController()
        {
            var lang = System.Configuration.ConfigurationManager.AppSettings["LuceneDefaultCulture"];

            _serviceStoreInstance = new LuceneService(App.Config.LuceneIndexFolder, JsonMappingUtils.GetAnalyser(lang));
        }