From Apertis
< Docs
Revision as of 10:03, 17 December 2014 by Pwith (talk | contribs) (Create page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contacts search

This allows to search for fields of contacts, and to get the results of the search sorted by full name if desired.


See query, simple-query, and search-view in the fuzzy branch here.

Basic explanation

  • Query contains basic definitions (constants, etc.)
  • SimpleQuery contains the search definitions (the query token and fields to match)
  • SearchView provides the means to retrieve the search results (using the query defined in SimpleQuery)
    • individuals returns a Map with the unsorted map of <, Individual> returned by the search
    • sorted_individuals returns a sorted List of Individuals
    • For a paged, sorted list, call get_sorted_page(int page_size, int page_num)

Folks-inspect option

A basic search option has been added to folks-inspect. It will search the name fields of contacts and output the matching contacts.


folks-inspect search [string]


Here is a basic example, extracted from folks-inspect tool

 using Folks;
 using Gee;
 using GLib;
 private class Folks.Inspect.Commands.Search : Folks.Inspect.Command
   public Search (Client client)
       base (client);
   public override async void run (string? command_string)
       if (command_string == null)
           /* A search string is required */
           Utils.print_line ("Please enter a search string");
           var query = new SimpleQuery (
             command_string, Query.MATCH_FIELDS_NAMES);
           var search_view = new SearchView (this.client.aggregator, query);
             yield search_view.prepare ();
           catch (GLib.Error e)
             GLib.warning ("Error when calling prepare: %s\n", e.message);
           foreach (var individual in search_view.individuals.values)
             Utils.print_individual (individual, true);