Skip to content
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

C# add ShowMatchesPosition in SearchQuery setting made search output error #428

Closed
jennyesoo opened this issue May 31, 2023 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@jennyesoo
Copy link

Describe the bug
Using ShowMatchesPosition in a SearchQuery, the search output fails to match the structure.

To Reproduce
Steps to reproduce the behavior:

  • SearchQuery setting

SearchQuery query = new SearchQuery { ShowMatchesPosition = true };

  • output is

image

  • I would like to search some query and then get error.

code is
ISearchable<IReadOnlyDictionary<string, string>> output = await _client.Index(_indexName).SearchAsync<IReadOnlyDictionary<string, string>>(input, query);

Error is
System.Text.Json.JsonException: 'The JSON value could not be converted to System.String. Path: $.hits[0]._matchesPosition | LineNumber: 0 | BytePositionInLine: 36568.'

  • check if There is an issue with the output structure in Meilisearch.ISearchable.cs

image

Expected behavior
The SearchAsync can be used flexibly.
ISearchable<T> output = await _client.Index(_indexName).SearchAsync<T>(input, query);

Meilisearch version:
Melisearch - [v1.2.0-rc.3]
C# -

@gillian-meilisearch gillian-meilisearch transferred this issue from meilisearch/meilisearch Jun 1, 2023
@gillian-meilisearch gillian-meilisearch added the support Issues related to support questions. label Jun 1, 2023
@alallema alallema added bug Something isn't working and removed support Issues related to support questions. labels Jun 5, 2023
@alallema
Copy link
Contributor

alallema commented Jun 5, 2023

Hi @jennyesoo,
Thanks for raising this issue! It's the week of the engine release, so I'll take a look as soon as I can.

@jennyesoo
Copy link
Author

Hi @jennyesoo, Thanks for raising this issue! It's the week of the engine release, so I'll take a look as soon as I can.

Thanks @alallema .

@ahmednfwela
Copy link
Collaborator

This is not a bug actually, you are deserializing to Dictionary<string, string> and since _matchesPosition is not a string, it will throw.

I suggest deserializing to JsonObject instead

@alallema
Copy link
Contributor

Thank you so much @ahmednfwela, you're absolutely right 🚀. Sorry I didn't read more carefully.
On that note I will close this issue because this is not a bug.

@jennyesoo
Copy link
Author

Hi, @ahmednfwela @alallema , thank you for your response.
I have now completed the conversion of the output to parse the JsonObject.
However, that is not the main point I want to emphasize.

When using ShowMatchesPosition, it generates two different output structures. My expectation is that SearchAsync should be flexible enough to handle these structures without requiring users to manually parse the JSON. Furthermore, ISearchable is unable to accurately interpret the structure.

I hope this conveys my intended message.

@ahmednfwela
Copy link
Collaborator

@jennyesoo a similar situation is addressed here for _formatted
#406

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants