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

Search Form does not show up when using Azure Search AI #15033

Closed
MikeAlhayek opened this issue Jan 10, 2024 · 4 comments · Fixed by #15035
Closed

Search Form does not show up when using Azure Search AI #15033

MikeAlhayek opened this issue Jan 10, 2024 · 4 comments · Fixed by #15035
Labels

Comments

@MikeAlhayek
Copy link
Member

MikeAlhayek commented Jan 10, 2024

There is a bug in the TheBlogTheme theme that I have no explanation for as of now. If you enable Azure Search AI and Search features, the search form does NOT show up.

To workaround this issue, you have to enabled either Lucene or Elasticsearch features for the search bar to show up.

When the request is made to /search endpoint, the line is reached https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Search/Controllers/SearchController.cs#L91

which returns the Search.cshtml view https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Search/Views/Search/Search.cshtml

That view would render Search__List shape, which then renders Search__Form and Search__Results shapes. What could be causing this views not to render?

Everything works using other themes like TheDefault theme which tells me that there is something about the blog theme that isn't working as it should.

azure-cognitive-search-4

@Skrypt Do you have any idea why this could be happening?

@Skrypt
Copy link
Contributor

Skrypt commented Jan 10, 2024

Shapes not instanciated or it throws a NRE somewhere. Would need to debug it.

@MikeAlhayek
Copy link
Member Author

@Skrypt shapes are instantiated from the Search module not the Search provider modules. Also, there is not error in the logs. The fact that everything works as expected in TheDefault theme tells me that the code is doing what it suppose. I am just puzzled with why the BlogTheme experience this behavior. TheBlogTheme is created using Liquid where as TheDefaultTheme is using Razor. I am not sure if this is an issue. I do not see any special liquid helpers that depends on the search providers either.

@MikeAlhayek
Copy link
Member Author

I figure out the issue finally.

Each provider was registering this independently

services.Configure<TemplateOptions>(o =>
{
    o.MemberAccessStrategy.Register<SearchIndexViewModel>();
    o.MemberAccessStrategy.Register<SearchFormViewModel>();
    o.MemberAccessStrategy.Register<SearchResultsViewModel>();
});

@Skrypt
Copy link
Contributor

Skrypt commented Jan 10, 2024

Yes these are ShapeViewModels ... strongly typed ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants