private void SetSearchAndExecute(QueryViewModel query) { QueryText = query.QueryText; SearchTypeOptions options = SearchTypeOptions.None; foreach (var item in query.Model.TokenQueries) { if (!options.HasFlag(item.SearchType)) { options = options | item.SearchType; } } if (options == SearchTypeOptions.Path) { ExecuteQuery(query.Model); } else { if (options == SearchTypeOptions.Tag) { IsTagSearch = true; } else if (options == SearchTypeOptions.None) { IsTagSearch = true; } else if (options == SearchTypeOptions.FullText) { IsTagSearch = false; } ExecuteQuery(); } }
internal SearchTypeOptions GetSearchType() { SearchTypeOptions options = SearchTypeOptions.None; TokenQueries.ForEach(q => { options = options | q.SearchType; }); return(options); }
private void ExecuteQuery() { SearchTypeOptions searchtype = _QueryText.StartsWith("/") ? SearchTypeOptions.Path : IsTagSearch ? SearchTypeOptions.Tag : SearchTypeOptions.FullText; var query = new Query().Parse(_QueryText, searchtype, QueryOperatorOption.Or, Settings.SelectedDomain.Id); ExecuteQuery(query); }
public static Query Parse(this Query query, IPathNode node, string domainId) { SearchTypeOptions searchType = SearchTypeOptions.Path; query.Operator = QueryOperatorOption.And; query.Domain = domainId; var token = node.Path; if (node.Path.StripSlug(out string slug, out string next)) { if (slug.Equals(AppConstants.Paths.Files)) { searchType = SearchTypeOptions.File; token = next.TrimStart('/'); } else if (slug.Equals(AppConstants.Paths.Default)) { token = next; } } else { var path = node.Path.TrimStart('/'); if (path.Equals(AppConstants.Paths.Files)) { // if just files, then all files searchType = SearchTypeOptions.File; } else if (path.Equals(AppConstants.Paths.Default)) { } else { // content } } //var pos = node.Path.IndexOf('/', 1); //token = pos > 0 ? node.Path.Substring(pos) : node.Path; query.TokenQueries.Add(new TokenQuery() { SearchType = searchType, Token = token }); return(query); }
public static Query Parse(this Query query, string input, SearchTypeOptions searchType, QueryOperatorOption operatorOption, string domainId) { query.Operator = operatorOption; query.Domain = domainId; if (!string.IsNullOrWhiteSpace(input)) { var tokens = input.SplitTrimLower().NormalizeQueryKeys(); foreach (var token in tokens) { query.TokenQueries.Add(new TokenQuery() { SearchType = searchType, Token = token }); } } return(query); }