Support non-semantic searches

Created on 10 August 2024, 5 months ago
Updated 11 August 2024, 5 months ago

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

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom jonathanshaw Stroud, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jonathanshaw
  • Pipeline finished with Success
    5 months ago
    Total: 141s
    #250047
  • Pipeline finished with Success
    5 months ago
    Total: 228s
    #250079
  • Pipeline finished with Success
    5 months ago
    Total: 138s
    #250082
  • 🇬🇧United Kingdom jonathanshaw Stroud, UK
  • Status changed to Needs review 5 months ago
  • 🇬🇧United Kingdom jonathanshaw Stroud, UK
  • Pipeline finished with Success
    5 months ago
    Total: 201s
    #250090
  • Pipeline finished with Success
    5 months ago
    Total: 136s
    #250654
  • Pipeline finished with Success
    5 months ago
    #250707
  • Pipeline finished with Canceled
    5 months ago
    Total: 68s
    #250718
  • Pipeline finished with Success
    5 months ago
    Total: 138s
    #250719
  • Pipeline finished with Canceled
    5 months ago
    Total: 74s
    #250726
  • Pipeline finished with Success
    5 months ago
    #250727
  • 🇬🇧United Kingdom jonathanshaw Stroud, UK

    Gitlab is struggling with a end of line character it won't let me change, but otherwise all good.

  • 🇧🇪Belgium interx Flanders

    Thank you for the feedback. We have chosen not to allow fully customizable query parameters via the UI. Instead the queryType will now be set to simple or semantic based on the schema version. I agree that this doesn't cover all variations, but at least will prevent many conflicting parameters.

    We have added a hook_search_api_aais_query_params_alter() to allow further customisations to the query. That allows anyone to set the query type and other parameters via code.

  • 🇧🇪Belgium interx Flanders
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024