-1

When I try to create a suggester on an index using .net sdk I get an error.

I can create index successfully using .net SDK but when I try to add suggester I get an error.

My index code:

var index = new Index()
{
Name = "customeridex",
Fields = FieldBuilder.BuildForType<AutocompleteResponseDetail>(),
Suggesters = new List<Suggester>() {new Suggester()
{
Name="cg",
SourceFields= new string[] { "Title", "Description" }
}}
};

The error message I get: 'The request is invalid. Details: definition: One or more fields in suggester 'cg' are not defined as a field in the index. Fields: Title, Description.'

Although I have fields: Title and description in my index

Dilshod K
  • 2,924
  • 1
  • 13
  • 46
Abdullah
  • 307
  • 2
  • 6
  • 16

2 Answers2

0

Try this :

 var definition = new Index()
            {
                Name = "customeridex",
                Fields = FieldBuilder.BuildForType<AutocompleteResponseDetail>(),
                Suggesters = new List<Suggester> {new Suggester("cg","Title", "Description") }
            };

I have tested on my side and it works for me.

Stanley Gong
  • 11,522
  • 1
  • 8
  • 16
0

My bad, it was casing error. Above sourcefields need to be all small to match index schema.

Abdullah
  • 307
  • 2
  • 6
  • 16