LSEG Data Library for .NET

SearchDefinition

Defines a Search request to idenfity a matching set of documents which satisfy a criteria, sorts it, and selects a subset of the matches to return as the result set. Each step can be controlled via parameters.

Syntax

ISearchDefinition Definition(ExploreView view = ExploreView.Entities)

ISearchDefinition Definition(View view)

ISearchDefinition Definition(LightView view)

Parameters

Value Description Data type
view A value representing the type of View the Search service shoudl use enum

Returned value

SearchDefinition object.

SearchDefinition Methods

ISearchDefinition View(Search.ExploreView view)

The supported View to search against the explore services.

The view is optional. Default: Search.ExploreView.Entities.

ISearchDefinition View(Search.View view)

The supported View to search against the full services.

The view is optional. Default: Search.ExploreView.Entities.

ISearchDefinition View(Search.LightView view)

The supported View to search against the light service.

The view is optional. Default: Search.ExploreView.Entities.

ISearchDefinition Query(string query)

The query expression defining freeform entry of search terms.

ISearchDefinition Filter(string filter)

Filter expression supports structured predicate expressions.

ISearchDefinition Select(string select)

A comma-separated list of the properties of a document to be returned in the response.

ISearchDefinition Boost(string boost)

Boost applies a scoring boost to documents it matches, which will almost always guarantee that they appear at the top of the results.

Boost supports exactly the same predicate expression syntax as Filter, except Filter restricts which documents are matched.

ISearchDefinition OrderBy(string order)

Defines the order in which matching documents should be returned. Default is by score descending.

ISearchDefinition GroupBy(string group)

Returned documents are grouped into buckets based on their value for this property.

ISearchDefinition GroupCount(uint count)

When supplied in combination with GroupBy, sets the maximum number of documents to be returned per bucket.

ISearchDefinition Top(uint top)

The maximum number of documents to retrieve. Default is 10. Must be non-negative.

A value of 0 returns no hits but sets the Total based on matches.

ISearchDefinition Skip(uint skip)

The number of documents to skip in the sorted result set before returning the next Top.

ISearchDefinition Navigators(string navigators)

This can name one or more properties, separated by commas, each of which must be Navigable.

ISearchDefinition Features(string features)

This can name one or more properties, separated by commas, each of which must be Navigable.

ISearchDefinition Closure(object closure)

Optionally, include a user-defined Closure to match specific requests and responses.

Usage

Below we have a provided a code snippet containing several search cases

// Search for Top CEOs where Apple appears in the document - Display DocumentTitle and its subtype/components.
// Note: Include an invalid property not related to people (BondType)
var request = Search.Definition()
                    .View(Search.View.SearchAll)
                    .Query("CEO Apple")
                    .Select("DocumentTitle, DTSubjectName, BondType, DTSimpleType, DTCharacteristics");

// Invalid request - ShortName can't be used in startswith function because it doesn't support the
// 'Exact' match capability.
request = Search.Definition(Search.View.Organisations)
                .Filter("startswith(ShortName,'H')");

// Search for past and present executives within Apple Inc.
request = Search.Definition(Search.View.People)
                .Filter("OfficerDirector(CompanyId eq '4295905573')")
                .Top(30)
                .Select("FullName, YearOfBirth, PrimaryTitleAsReported");


// Search for all the RICs where 'LSE' is in the name, exclude all derivatives and ensure the state is active (AC)
request = Search.Definition(Search.View.Quotes)
                .Filter("TickerSymbol eq 'LSE' and AssetType ne 'derivative' and AssetState eq 'AC'")
                .Select("AssetState, DTSubjectName, DTSimpleType, DTSource, DTCharacteristics, RIC, SearchAllCategoryv3, AssetType");

// Oil refineries in Venezula, Especially ones that arzen't currently operational (Boost plant status).
request = Search.Definition(Search.View.PhysicalAssets)
                .Filter("RCSAssetTypeLeaf eq 'oil refinery' and RCSRegionLeaf eq 'Venezuela'")
                .Boost("PlantStatus ne 'Normal Operation'")
                .Select("DocumentTitle, PlantStatus")
                .Top(100);

// The youngest CEO's
request = Search.Definition(Search.View.People)
                .Query("ceo")
                .OrderBy("YearOfBirth desc,LastName,FirstName")
                .Select("YearOfBirth, name"); 

// Top currencies for Gov Corp Bonds
request = Search.Definition(Search.View.GovCorpInstruments)
                .Top(0)
                .Navigators("Currency(buckets:5,desc:sum_FaceOutstandingUSD,calc:max_CouponRate)");

// Top 2 rate indicators for each central bank
request = Search.Definition(Search.View.IndicatorQuotes)
                .Query("rates")
                .GroupBy("CentralBankName")
                .GroupCount(2)
                .Select("CentralBankName,DocumentTitle,RIC");

// Top 10 Gov Corp instruments for specific range of coupon rates and ratings.
// Note: "_" in Select means to include default fields.
var filter = "RatingsScope(RatingType eq 'MBU') and AssetState eq 'AC'";
request = Search.Definition(Search.View.GovCorpInstruments)
                .Top(10)
                .Filter(filter)
                .Select("_, RatingsScope(filter:((RatingType xeq 'MBU'))), RatingX1XRatingRank");

// Use _debugall as a tool to inspect all available Properties for a given search
request = Search.Definition(Search.View.SearchAll)
                .Query("CFO IBM")
                .Top(1)
                .Select("_debugall");

// Search for all the RICs where 'LSE' is in the name, exclude all derivatives and ensure the state is active (AC)
request = Search.Definition()
                .View(Search.LightView.EquityQuotes)
                .Filter("TickerSymbol eq 'LSE' and AssetType ne 'derivative' and AssetState eq 'AC'")
                .Select("DocumentTitle, AssetState, RIC, SearchAllCategoryv3, AssetType");

request = Search.Definition()
                .View(Search.LightView.SearchAllLight)
                .Filter("IssuerName eq 'US Treasury' and Currency eq 'USD' and SearchAllCategoryv3 eq 'Bonds' and IsActive eq true")
                .Select("RIC,ISIN,IssuerName,MaturityDate,CouponRate");

// Top currencies for Gov Corp Bonds
request = Search.Definition(Search.LightView.GovCorpInstruments)
                .Top(0)
                .Navigators("Currency(buckets:5,calc:max_CouponRate)");

// Top 2 rate indicators for each central bank
request = Search.Definition(Search.LightView.IndicatorQuotes)
                .Query("rates")
                .GroupCount(2)
                .Select("DocumentTitle,RIC");

// Find any data on Bill Gates
request = Search.Definition(Search.LightView.SearchAllLight)
                .Query("Bill Gates");