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)); }
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)); }
/// <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); }
/// <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); }
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; } }
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; } }
/// <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); }
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); }
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); }
/// <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); }
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); }
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)); }
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)); }
public static TopDocs Search(this Searcher searcher, string type, Query query, int numResults) { return(searcher.Search(query, JsonMappingUtils.GetTypeFilter(type), numResults)); }
private LuceneController() { _serviceInstance = new LuceneService(AppConfig.Instance.LuceneIndexFolder, JsonMappingUtils.GetAnalyser()); }
private static void DeleteAllOfType(LuceneController lc, string scope) { var selection = JsonMappingUtils.CreateTypeQuery(scope); lc.Store.Delete(selection); }
private LuceneController() { var lang = System.Configuration.ConfigurationManager.AppSettings["LuceneDefaultCulture"]; _serviceStoreInstance = new LuceneService(App.Config.LuceneIndexFolder, JsonMappingUtils.GetAnalyser(lang)); }