public TextSearchResult Search(int tenantId, string query, string module) { try { if (string.IsNullOrEmpty(module)) throw new ArgumentNullException("module"); var result = new TextSearchResult(module); if (string.IsNullOrEmpty(query)) { return result; } if (TextIndexCfg.MaxQueryLength < query.Length) { query = query.Substring(0, TextIndexCfg.MaxQueryLength); } var tenant = CoreContext.TenantManager.GetTenant(tenantId); var path = configuration.GetIndexPath(tenantId, module); if (tenant == null || !Directory.Exists(path)) return result; var searcher = new TextSearcher(module, path); return searcher.Search(query, tenant); } catch (Lucene.Net.QueryParsers.ParseException ex) { throw new ArgumentException(ex.Message); } }
public string[] Search(int tenantId, string query, string module) { log.DebugFormat("Search({0}, {1}, {2})", tenantId, 50 < (query ?? string.Empty).Length ? query.Substring(0, 50) + "..." : query, module); try { if (string.IsNullOrEmpty(module)) { throw new ArgumentNullException("module"); } if (string.IsNullOrEmpty(query)) { return(new string[0]); } if (TextIndexCfg.MaxQueryLength < query.Length) { query = query.Substring(0, TextIndexCfg.MaxQueryLength); } var tenant = tenantsProvider.GetTenant(tenantId); var path = configuration.GetIndexPath(tenantId, module); if (tenant == null || !Directory.Exists(path)) { return(new string[0]); } var searcher = new TextSearcher(module, path); return(searcher.Search(query, tenant)); } catch (Lucene.Net.QueryParsers.ParseException ex) { log.ErrorFormat("Search error: query = {0}, tenantId = {1}, module = {2} - {3}", query, tenantId, module, ex); throw new ArgumentException(ex.Message); } }
public TextSearchResult Search(int tenantId, string query, string module) { try { if (string.IsNullOrEmpty(module)) { throw new ArgumentNullException("module"); } var result = new TextSearchResult(module); if (string.IsNullOrEmpty(query)) { return(result); } if (TextIndexCfg.MaxQueryLength < query.Length) { query = query.Substring(0, TextIndexCfg.MaxQueryLength); } var tenant = CoreContext.TenantManager.GetTenant(tenantId); var path = configuration.GetIndexPath(tenantId, module); if (tenant == null || !Directory.Exists(path)) { return(result); } var searcher = new TextSearcher(module, path); return(searcher.Search(query, tenant)); } catch (Lucene.Net.QueryParsers.ParseException ex) { throw new ArgumentException(ex.Message); } }