/// <summary> /// IAs the utocomplete. on searching. /// <para xml:lang="es">Es la funcion de autocompletar al hacer la busqueda</para> /// </summary> /// <returns>The utocomplete. on searching. /// <para xml:lang="es">El autocompletar en la busqueda.</para> /// </returns> /// <param name="text">Text. /// <para xml:lang="es">El texto.</para> /// </param> AutocompleteSearchEventArgs IAutocomplete.OnSearching(string text) { AutocompleteSearchEventArgs e = new AutocompleteSearchEventArgs(text); Searching?.Invoke(this, e); return(e); }
public AutocompleteSearchEventArgs OnSearching(string text) { var e = new AutocompleteSearchEventArgs(text); Searching?.Invoke(this, e); return(e); }
/// <summary> /// Ons the searching. /// <para xml:lang="es"> /// El argumento de la busqueda paraseleccionar un elemento del Autocomplete. /// </para> /// </summary> /// <returns>The searching.</returns> /// <param name="text">Text.</param> public AutocompleteSearchEventArgs OnSearching(string text) { AutocompleteSearchEventArgs e = new AutocompleteSearchEventArgs(text); Searching?.Invoke(this, e); ResultView = new global::Xamarin.Forms.ListView(); ResultView.ItemsSource = e.SearchResult; ResultView.ItemSelected += ResultView_ItemSelected; ResultPage = new global::Xamarin.Forms.ContentPage(); ResultPage.Content = ResultView; ((Page)Platform.Current.Page).Navigation.PushAsync(ResultPage); return(e); }
public virtual IEnumerable <ISearchable> Search(string filter, int maxResults = SearchDefaults.DefaultResults) { Initialize(); var results = new List <ISearchable>(); lock (_lockObject) { try { Searching?.Invoke(this, new SearchEventArgs(filter, results)); Query finalQuery = null; // Note: There are two issues with using regex here // 1. Lucene uses lower case interpretation of each string for indexing. // That means in regular expression we can use only lower case characters // 2. escape sequences do not work. Not sure why // // In order to fix (1), we have to force Lucene to index differently. Probably we need to have two // versions if indeces. One for regular search and another for regex // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (filter.IsValidOrcSearchFilter()) { using (var analyzer = new StandardAnalyzer(LuceneDefaults.Version)) { var queryAsText = _searchQueryService.GetSearchQuery(filter, GetSearchableMetadata()); var parser = new QueryParser(LuceneDefaults.Version, string.Empty, analyzer); finalQuery = parser.Parse(queryAsText); } } if (finalQuery != null) { using (var indexReader = DirectoryReader.Open(_indexDirectory)) { var searcher = new IndexSearcher(indexReader); var search = searcher.Search(finalQuery, maxResults); foreach (var scoreDoc in search.ScoreDocs) { var docId = scoreDoc.Doc; var doc = searcher.Doc(docId); var index = int.Parse(doc.Get(IndexId)); results.Add(_indexedObjects[index]); } } } } catch (ParseException ex) { Log.Warning(ex, "Failed to parse search pattern"); } catch (Exception ex) { Log.Error(ex, "An error occurred while searching, returning default results"); } finally { Searched?.Invoke(this, new SearchEventArgs(filter, results)); } } return(results); }