AleksandrRogov / DynamicsWebApi

DynamicsWebApi is a Microsoft Dataverse Web API helper library for JavaScript & TypeScript
MIT License
268 stars 58 forks source link

Implement Dataverse Search API #134

Closed AleksandrRogov closed 1 year ago

AleksandrRogov commented 1 year ago

Add new functions that make requests to Dataverse Search API. More Info.

The configuration object has been changed to allow for multiple APIs to be queried. Check issue #139 for more info.

Per Microsoft documentation 3 functions need to be added:

autocomplete:

Property Name Type Description
search string The search parameter value contains the term to be searched for and has a 100-character limit.
entities string[] The default table list searches across all Dataverse search–configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled.
filter string Filters are applied while searching data and are specified in standard OData syntax.
useFuzzy boolean Use fuzzy search to aid with misspellings. The default is false.

search:

Property Name Type Description
search string The search parameter value contains the term to be searched for and has a 100-character limit.
entities string[] The default table list searches across all Dataverse search–configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled.
facets string[] Facets support the ability to drill down into data results after they've been retrieved.
filter string Filters are applied while searching data and are specified in standard OData syntax.
orderBy string[] A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence.
returnTotalRecordCount boolean Specify true to return the total record count; otherwise false. The default is false.
searchMode string Specifies whether any or all the search terms must be matched to count the document as a match. The default is 'any'.
searchType string The search type specifies the syntax of a search query. Using 'simple' selects simple query syntax and 'full' selects Lucene query syntax. The default is 'simple'.
skip number Specifies the number of search results to skip.
top number Specifies the number of search results to retrieve. The default is 50, and the maximum value is 100.

suggest:

Property Name Type Description
search string The search parameter value contains the term to be searched for and has a 3-character min limit and max 100-character limit.
entities string[] The default table list searches across all Dataverse search–configured tables and columns. The default list is configured by your administrator when Dataverse search is enabled.
orderBy string[] A list of comma-separated clauses where each clause consists of a column name followed by 'asc' (ascending, which is the default) or 'desc' (descending). This list specifies how to order the results in order of precedence.
filter string Filters are applied while searching data and are specified in standard OData syntax.
top number Number of suggestions to retrieve. The default is 5.
useFuzzy boolean Use fuzzy search to aid with misspellings. The default is false.

Additional tasks to be done:

The development must be done on typescript branch or branches derived from typescript.

AleksandrRogov commented 1 year ago

After the fact, I added short form function calls for all 3, like:

await dynamicsWebApi.search("search term");
await dynamicsWebApi.suggest("search term");
await dynamicsWebApi.autocomplete("search term");

I feel like this is going to be helpful and should be used a lot.