Problem/Motivation
I tried to use this module with Azure AI Search's free plan, which does not include semantic ranking. I hit a large set of problems:
- There is no way for a sitebuilder to specify 'full' rather than 'semantic' as the query type
- The 'answers' param is added to the query even if 'full' is specified, when that is invalid
- The 'semantic configuration' index option is required for certain API versions, but actually it should never be required because it's only needed for semantic searches
- Even if views can specify semantic, an error is logged when the index is viewed because viewing the index triggers a query that defaults to semantic.
Proposed resolution
Swap out the SearchApiQuery views query plugin class and add additional options if the view operates on an Azure AI Search index. In the QueryParamBuilder, respect the options specified on the query.
Additionally, the default query type in QueryParamBuilder should be changed to simple so that routine admin operations like viewing the index don't require the server to have semantic capability.
Rejected solutions
(1) Use hook_views_query_alter to set a 'search_api_aais_query_type' param on the query, and form alter and 3rd party settings to allow a sitebuilder to specify the query type in the views query settings. This approach is complex.
(2) Create a new Views Query plugin extending the SearchApiQuery plugin provided by search_api with additional options. This is a good approach, but unfortunately Search API has considerable logic that looks for a views plugin with id 'search_api_query', so providing an alternative plugin is not straightforward.
(3) Instead of changing the default query type in QueryParamBuilder to 'simple', we could instead intercept any query tagged with 'server_index_status' and set that to simple.
(4) We could simply silently change the query type of any query to 'full' if semantic configuration is not available. However, this has the danger of burying genuine configuration problems without warning.
Remaining tasks
User interface changes
A new configuration option 'Azure AI Search query type' is available in the views query settings.
API changes
The default query type for queries is now 'simple'. However, this won't break BC for views queries as those default to using 'semantic' unless explicitly configured otherwise.
Data model changes
None