It's not clear how you would like suggesters to work in your case. The simplest approach to start with is to:
-
Map a field with the
completion
datatypepublic class Question { public CompletionField TitleSuggest { get; set; } } var createIndexResponse = client.CreateIndex("my_index", c => c .Mappings(m => m .Map<Question>(u => u .AutoMap() ) ) );
-
Index a document with completion inputs
var question = new Question { TitleSuggest = new CompletionField { Input = new[] { "This is the title" }, Weight = 5 } }; client.Index(question, i => i.Index("my_index").Refresh(Refresh.WaitFor));
-
Search using the completion suggester
var response = client.Search<Question>(s => s .Index("my_index") .Suggest(su => su .Completion("suggested_titles", cs => cs .Field(f => f.TitleSuggest) .Prefix("This is") .Fuzzy(f => f .Fuzziness(Fuzziness.Auto) ) .Size(5) ) ) ); // do something with suggestions var suggestions = from suggest in response.Suggest["suggested_titles"] from option in suggest.Options select new { Id = option.Source.Id, Text = option.Text };