AI OnAI Off
I have similar code working fine. Could you try using parent id instead of reference as string?
Category = relation.Parent.ID.ToString(),
So the issue was hidden in the IClient instantiation. Make sure used IClient instance is singleton.
The easiest way to do that is to inject IClient via constructor:
private readonly IClient _client;
public SearchProvider(IClient client)
{
_client = client;
}
Sharing additional details according to the Quan Mai ask.
In the previous implementation we had combo wombo of 2 things.
1) IClient creation (not injection):
private readonly Lazy<IClient> _client;
public SearchProvider()
{
_client = new Lazy<IClient>(Client.CreateFromConfig);
}
2) SearchProvider transient lifecycle:
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Services.AddTransient<ISearchProvider, SearchProvider>();
}
So it causes new IClient instance creation every time when SearchProvider gets called.
And I believe at some moment IClient instance doesn't know about all previously registered custom conventions. And that's why actual search request query is not properly built.
Hello,
I'm trying to make working query with sorting by nested object.
I have the following extension method:
which I register with custom conventions:
As a result I can see the following data in my Find index:
or in case of no relations:
And what I do during actual search is:
but unfortunately I receive the following exception:
All other requests without such sorting work fine without any issues.
Thanks