-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the Text property in a TermSuggester or PhraseSuggester results in a parsing exception #8310
Comments
Hi @Lukyb14, I can not reproduce this issue. I assume the way you are building the query is incorrect. The following code: var termSuggester = FieldSuggester.Term(new TermSuggester
{
Analyzer = "term_search_analyzer",
Field = "term"!,
PrefixLength = 2,
Size = 10,
Sort = SuggestSort.Score
});
termSuggester.Text = "elastic";
var response = await client.SearchAsync<Person>(new SearchRequest("person")
{
Query = Query.MatchAll(new MatchAllQuery()),
Suggest = new Suggester
{
Text = "elastic",
Suggesters = new Dictionary<string, FieldSuggester>
{
{ "0", termSuggester }
}
}
}); as well as the equivalent fluent-style code: var response = await client.SearchAsync<Person>(r => r
.Index("person")
.Query(q => q.MatchAll(_ => {}))
.Suggest(suggest => suggest
.Suggesters(suggesters => suggesters
.Add("0", suggester => suggester
.Term(term => term
.Analyzer("term_search_analyzer")
.Field("term"!)
.PrefixLength(2)
.Size(10)
.Sort(SuggestSort.Score)
)
.Text("elastic")
)
)
)
); correctly produces the expected JSON request: {
"query": {
"match_all": {}
},
"suggest": {
"0": {
"text": "elastic",
"term": {
"analyzer": "term_search_analyzer",
"field": "term",
"prefix_length": 2,
"size": 10,
"sort": "score"
}
}
}
} You were probably using the |
That is correct, I was using this property. I was not aware the FieldSuggester type has a Text property as well, and just assumed it would use the TermSuggester Text property. I just wanted to add that I noticed that the PhraseSuggester also has a Text property, which creates a similar invalid request, if it is set. Thank you for providing the correct examples. |
@Lukyb14 We double checked and it seems like the text property was indeed incorrectly added to these two suggester variants. I'll make sure to remove them from our specification 🙂 Thanks for reporting! |
Elastic.Clients.Elasticsearch version: 8.15.2
Elasticsearch version: 8.15.0
.NET runtime version: .NET 8
Operating system version: Windows 10
Description of the problem including expected versus actual behavior:
When using the SearchRequest with a FieldSuggester, where the Text property is set, the ElasticsearchClient sends a request with the text field not set in the correct place. The server then responds with a parsing error.
This is an example of an invalid generated suggester:
The "term" object does not support the field "text", so therefore the server returns with a parsing exception.
Steps to reproduce:
Expected behavior
The client should generate a valid request, where the "text" property is next to the "term" property.
Provide
DebugInformation
(if relevant):The text was updated successfully, but these errors were encountered: