Skip to content

Getting Started

Giacomo Stelluti Scala edited this page Jan 25, 2020 · 13 revisions

Install

A version quite aligned to GitHub repository can be downloaded from NuGet. It follows the command of .NET Core CLI tool:

$ dotnet add package PickAll --version 0.23.0-beta

This will install the specified version of PickAll. In a similar way can achieve the same result from Visual Studio Package Manager Console:

PM> Install-Package PickAll -Version 0.23.0-beta

Context

Each predefined set of searches or post processing events (defined service) must occur on a search context (SearchContext type). You can get one using Default preconfigured singleton:

var context = SearchContext.Default;

This is the equivalent of:

var context = SearchContext()
                  .With<Goolge>()
                  .With<DuckDuckGo>()
                  .With<Uniqueness>()
                  .With<Order>();

This will create a context able to produce results using Google and DuckDuckGo. Results will be unique by URL and ordered by index (this will enforce relevance). Something similar can be easly done using the F# friendly constructor:

let context = new SearchContext(typeof<Google>,
                                typeof<DuckDuckGo>,
                                typeof<Uniqueness>,
                                typeof<Order>)

There are also other means to configure services, but no result is created until a call to SearchAsync:

var query = "quantum physics";
var results = await context.SearchAsync(query);

Very similar in F#:

let query = "quantum physics"
let results = context.SearchAsync("steve jobs")
                        |> Async.AwaitTask
                        |> Async.RunSynchronously

Results

Results gathered and processed by services are a sequence of the immutable ResultInfo type, defined with the following public interface:

public class ResultInfo
{
    public string Originator { get; } // The searcher which originated the result.
    public ushort Index { get; } // The result index.
    public string Url { get; } // The result URL.
    public string Description { get; } // The result description.
    public object Data { get; } // // Additional data supplied by the service.
}

After you get your ResultInfo sequence, you can process it the way you want. E.g. using LINQ:

var urls = from result in results
           where result.Destription.ToLower().Contains("higgs")
           select result.Url;
Clone this wiki locally