public virtual QuranSearchResult SearchInArabic(string searchText) { var words = searchText.Split(' '); var s = new StorageService(); var resource = new QuranSearchResult(); resource.ResultCategories = new List <SearchResultCategory>(); var rootMatches = GetRootMatches(words, s); if (rootMatches.Results.Any()) { resource.ResultCategories.Add(rootMatches); } resource.ResultCategories.AddRange(GetRootMatchesByForm(words, s)); //var roots = s.SetOf<Root>().Where(r => words.Any(w => w == r.Text)).ToList(); //var rootResults = roots.SelectMany(r => BuildSearchCategories(r.RootUsages.Select(u => u.WordPart), "Root match")).ToList(); //var exactUnmodifiedFormMatches = s.SetOf<UnmodifiedWordPart>().Where(r => words.Any(w => w == r.Text)).ToList(); //var exactUnmodifiedResults = exactUnmodifiedFormMatches.SelectMany(e => BuildSearchCategories(e.Usages.Select(u => u.WordPart),"Form match")).ToList(); //var exactWholeFormMatches = s.SetOf<WordPart>().Where(r => words.Any(w => w == r.Text)).ToList(); //var exactResults = BuildSearchCategories(exactWholeFormMatches, "Exact match").ToList(); //resource.ResultCategories = exactResults.Union(rootResults).ToList(); resource.SearchText = searchText; s.Dispose(); return(resource); }
public virtual QuranSearchResult SearchInEnglish(string searchText) { var verseTranslations = _storageService.SetOf <VerseTranslation>().Where(r => r.Text.Contains(searchText)).ToList(); var resource = new QuranSearchResult(); resource.ResultCategories = new List <SearchResultCategory> { new SearchResultCategory { MatchType = "English verse matches", Match = "\"" + searchText + "\"", Results = verseTranslations.Select(v => BuildVerseResult(v)).ToList() } }; resource.SearchText = searchText; return(resource); }