Search code examples
odataasp.net-web-api2

$Search not working in odata web api 2


I am unable to determine how to get $search parameter to work for full text search in odata.

The following url indicates that it should be included in 6.1 http://blogs.msdn.com/b/odatateam/archive/2014/03/21/odata-6-1-and-odata-client-6-1-are-now-shipped.aspx

I have created a sample application using the following template http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint

When I execute the odata query http://localhost:53621/odata/PartnerMaster?%24format=json&%24top=100&%24orderby=PartnerName&%24search=Test

I receive the error message. message=The query parameter '$search' is not supported


Solution

  • :) See you again. Copy the answer here to let more people aware of it.

    ODL supports to parse the $search query option, however, Web API OData doesn’t support it so far.

    While, in ODL, you can refer the following test cases:

    https://github.com/OData/odata.net/blob/master/test/EndToEndTests/Tests/Client/Build.Desktop/TripPinServiceTests/TripPinServiceTests.cs#L515-L576

    https://github.com/OData/odata.net/tree/ae0dd29c1cf430255a8ec9c4225b4745e25cad64/test/FunctionalTests/Tests/DataOData/Tests/OData.Scenario.Tests/UriParser/Search

    https://github.com/OData/odata.net/tree/ae0dd29c1cf430255a8ec9c4225b4745e25cad64/test/FunctionalTests/Tests/DataOData/Tests/OData.Scenario.Tests/UriParser/SearchCombination