1

Currently, I have the Elasticsearch service running on version 7.4.0 while my C# Windows Form application is using Elasticsearch.Net version 7.3.1.

I notice I could set the maximum number of results returned from highlight by setting NumberOfFragments which by default is five. However, I could not get the completion/suggestion to return more than five results when I set the following:

                    var tRes = client.Search<Words>(s => s
                        .SuggestSize(20) // How many suggestions to return in response
                        .Suggest(su => su
                        .Completion("name", cs => cs
                                .SkipDuplicates(true)
                                .Field(f => f.Suggest)
                                .Prefix(tbInput.Text)
                                .Regex("*")
                                .Size(20))
                        )

I received the following error message when I execute the above query.

{"The remote server returned an error: (400) Bad Request.. Call: Status code 400 from: POST /docproperty/_search?typed_keys=true&suggest_size=20. ServerError: Type: illegal_argument_exception Reason: \"request [/docproperty/_search] contains unrecognized parameter: [suggest_size] -> did you mean [suggest_field]?\""}

Update

I manage to get more than 5 results by adding the following:

                    var tRes = client.Search<Words>(s => s
                        .Size(20)
                        .Suggest(su => su
                        .Completion("name", cs => cs
                                .SkipDuplicates(true)
                                .Field(f => f.Suggest)
                                .Prefix(tbInput.Text)
                                .Regex("*")
                                .Size(20))
                                .Term("", t=>t.ShardSize(20).Field(f=>f.Suggest).Text(tbInput.Text))
                        )
                    );

However, this time I notice that I could not get the completion to return words (a lot of missing ones) that could be found when I execute a MatchPhrase.

Keith Loo
  • 35
  • 4

1 Answers1

1

I think if you look at the documentation, I think it's not meant to be suggestSize. I think it should be size only.. not sure if this supports chaining.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html

Abd Rmdn
  • 480
  • 4
  • 11
  • I find that the size attribute is kind of buggy for this case. I have to set the outer and inner size attribute for it to work. E.g. I have the following words added. gabby, gable, gadget, gaffe, gag, gaggle ,gag order, gaiety. I get the first 5 when I set the size to '6' while I get the first 6 when I set the size to '10'. – Keith Loo Dec 24 '19 at 01:53
  • I see.. It is weird tbh. do you mean that the outout of it differs based on the size? – Abd Rmdn Dec 30 '19 at 10:43