I am trying to create index for for below model.
public class Booking
{
[System.ComponentModel.DataAnnotations.Key]
[IsSearchable,IsFilterable,IsSortable]
public string BookId { get; set; }
[IsSearchable, IsFilterable]
public string BooknName { get; set; }
}
Code to create index
FieldBuilder fieldBuilder = new FieldBuilder();
var searchFields = fieldBuilder.Build(typeof(Booking));
var definition = new SearchIndex(indexName, searchFields);
indexClient.CreateOrUpdateIndex(definition);
But this somehow ignores the IsSearchable/IsFilterable
when I look at the definition and create the index with setting all this to false
Is there any other property i am missing here? I am using Azure.Search.Documents - Version=11.1.1.0
Since you're instantiating FieldBuilder
, I assume you're using Azure.Search.Documents
. In that case, you need to use the new attributes we added, such as SearchableFieldAttribute
. The previous attributes effectively correspond to properties. See https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/search/Azure.Search.Documents/samples/Sample04_FieldBuilderIgnore.md for an example.
Microsoft.Azure.Search
will soon be deprecated, BTW.