Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Goal

This article contains information about the implementation of the searching process. The C# SDK exposes a method which can be used to make search requests to the Hawksearch API.

Prerequisite

Configured Connector - Configure Hawksearch


The Search method exposes a functionality to make search requests to the Hawksearch API.

SearchResult Search(SearchQuery query);

Parameters

  • SearchQuery query

 SearchQuery properties
    public string ClientGuid { get; set; }

    public string IndexName { get; set; }

    public string Keyword { get; set; }

    public int PageNo { get; set; }

    public int MaxPerPage { get; set; }

    public string SortBy { get; set; }

    public string CustomUrl { get; set; }

    public string SortingSetCode { get; set; }

    public string SearchWithin { get; set; }

    public List<string> FacetOverride { get; set; }

    public List<string> FieldOverride { get; set; }

    public ClientData ClientData { get; set; }

    public bool IsInPreview { get; set; }

    public string ExplainDocId { get; set; }

    public List<object> SmartBar { get; set; }

    public bool BoostAndBury { get; set; }

    public bool VisibilityRules { get; set; }

    public bool PersonalizedBoost { get; set; }

    public bool PopularityBoost { get; set; }

    public bool ItemPin { get; set; }

    public bool Is100CoverageTurnedOn { get; set; }

    public Dictionary<string, List<object>> FacetSelections { get; set; }

The SearchQuery object should contain all the information needed to make the request to the Hawksearch API. The mandatory ones are ClientGuid,IndexName,Keyword and FacetSelections.

Returns

  • SearchResult

The Hawksearch API responds with a message which is the mapped to an object of type SearchResult

 SearchResult properties

        public List<Facet> Facets { get; set; }

        public List<object> VisitorTargets { get; set; }

        public Guid TrackingId { get; set; }

        public bool Success { get; set; }

        public Pagination Pagination { get; set; }

        public string Keyword { get; set; }

        public List<Result> Results { get; set; }

        public Redirect Selections { get; set; }

        public FeaturedItems Sorting { get; set; }

        public Redirect Redirect { get; set; }

        public FeaturedItems Merchandising { get; set; }

        public FeaturedItems FeaturedItems { get; set; }

        public long SearchDuration { get; set; }

The search results are deserialized and mapped to a List<Result> Results

 Result properties
    public Guid DocId { get; set; }

    public long Score { get; set; }

    public Dictionary<string, List<string>> Document { get; set; }

    public Redirect BestFragments { get; set; }

    public bool IsPin { get; set; }

Usage

Call this method when you want to make search requests to the Hawkseach API.

Autocomplete


The Autocomplete method exposes a functionality for autocompleting search request depending on input.

 AutocompleteResult Autocomplete(AutocompleteQuery query)

Parameters

  • AutocompleteQuery query

This is the data which is expected in order to make a successful autocomplete request

 AutocompleteQuery properties
public string ClientGuid { get; set; }

public string Keyword { get; set; }

public string IndexName { get; set; }

public string Type { get; set; }

public long ProductCount { get; set; }

public bool DisplayFullResponse { get; set; }

public string[] FieldOverride { get; set; }

public ClientData ClientData { get; set; }

The mandatory ones are ClientGuid, Keyword, IndexName, DisplayFullResponse.

Returns

  • AutocompleteResult

The Hawksearch API returns a response message which is mapped to object of type AutocompleteResult

 AutocompleteResult properties
public long Count { get; set; }

public long ContentCount { get; set; }

public List<Category> Categories { get; set; }

public List<Product> Products { get; set; }

public List<object> Content { get; set; }

public List<object> Popular { get; set; }

public string SearchWebsiteUrl { get; set; }

public string KeywordField { get; set; }

public string CategoryHeading { get; set; }

public string ContentHeading { get; set; }

public string ProductHeading { get; set; }

public string PopularHeading { get; set; }

public string ViewAllButtonLabel { get; set; }

The actual autocomplete results are mapped to a List<Product> Products

 Product properties
public string ProductName { get; set; }

public string Thumb { get; set; }

public string Url { get; set; }

public string Html { get; set; }

public Result Results { get; set; }

And the data for each result is mapped to an object of type Result

 Result properties
public Guid DocId { get; set; }

public long Score { get; set; }

public Dictionary<string, List<string>> Document { get; set; }

public Redirect BestFragments { get; set; }

public bool IsPin { get; set; }

Usage

Call this method when you want to enhance your UI by

  • No labels