diff --git a/app/controllers/discourse_ai/embeddings/embeddings_controller.rb b/app/controllers/discourse_ai/embeddings/embeddings_controller.rb
index a202c709..a512bc55 100644
--- a/app/controllers/discourse_ai/embeddings/embeddings_controller.rb
+++ b/app/controllers/discourse_ai/embeddings/embeddings_controller.rb
@@ -8,7 +8,11 @@ module DiscourseAi
SEMANTIC_SEARCH_TYPE = "semantic_search"
def search
- query = params[:q]
+ query = params[:q].to_s
+
+ if query.length < SiteSetting.min_search_term_length
+ raise Discourse::InvalidParameters.new(:q)
+ end
grouped_results =
Search::GroupedSearchResults.new(
diff --git a/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.hbs b/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.hbs
index 9b71af92..0d100374 100644
--- a/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.hbs
+++ b/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.hbs
@@ -3,7 +3,6 @@
{{#if this.searching}}
diff --git a/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.js b/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.js
index 58f981d4..90cf8d83 100644
--- a/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.js
+++ b/assets/javascripts/discourse/connectors/full-page-search-below-search-header/semantic-search.js
@@ -3,7 +3,7 @@ import { action, computed } from "@ember/object";
import I18n from "I18n";
import { tracked } from "@glimmer/tracking";
import { ajax } from "discourse/lib/ajax";
-import { translateResults } from "discourse/lib/search";
+import { isValidSearchTerm, translateResults } from "discourse/lib/search";
import discourseDebounce from "discourse-common/lib/debounce";
import { inject as service } from "@ember/service";
import { bind } from "discourse-common/utils/decorators";
@@ -15,6 +15,7 @@ export default class extends Component {
}
@service appEvents;
+ @service siteSettings;
@tracked searching = true;
@tracked collapsedResults = true;
@@ -25,9 +26,12 @@ export default class extends Component {
return this.args.outletArgs.search;
}
- @computed("args.outletArgs.type")
+ @computed("args.outletArgs.type", "searchTerm")
get searchEnabled() {
- return this.args.outletArgs.type === SEARCH_TYPE_DEFAULT;
+ return (
+ this.args.outletArgs.type === SEARCH_TYPE_DEFAULT &&
+ isValidSearchTerm(this.searchTerm, this.siteSettings)
+ );
}
@computed("results")
@@ -57,7 +61,7 @@ export default class extends Component {
@bind
performHyDESearch() {
- if (!this.searchTerm || !this.searchEnabled) {
+ if (!this.searchEnabled) {
return;
}