@@ -56,7 +56,6 @@ function attach_elastic_search_query_sphinx(data) {
56
56
search_def
57
57
. then ( function ( data ) {
58
58
var hit_list = data . results || [ ] ;
59
- var total_count = data . count || 0 ;
60
59
61
60
if ( hit_list . length ) {
62
61
for ( var i = 0 ; i < hit_list . length ; i += 1 ) {
@@ -272,9 +271,14 @@ function attach_elastic_search_query_sphinx(data) {
272
271
} ;
273
272
274
273
if ( typeof Search !== 'undefined' && project && version ) {
275
- var query_fallback = Search . query ;
276
- Search . query_fallback = query_fallback ;
277
- Search . query = query_override ;
274
+ // Do not replace the built-in search if RTD's docsearch is disabled
275
+ if ( ! data . features || ! data . features . docsearch_disabled ) {
276
+ var query_fallback = Search . query ;
277
+ Search . query_fallback = query_fallback ;
278
+ Search . query = query_override ;
279
+ } else {
280
+ console . log ( 'Server side search is disabled.' ) ;
281
+ }
278
282
}
279
283
$ ( document ) . ready ( function ( ) {
280
284
if ( typeof Search !== 'undefined' ) {
@@ -409,19 +413,18 @@ function attach_elastic_search_query_mkdocs(data) {
409
413
}
410
414
411
415
412
-
413
416
function init ( ) {
414
417
var data = rtddata . get ( ) ;
415
- // Do not replace the built-in search if RTD's docsearch is disabled
416
- if ( ! data . features || ! data . features . docsearch_disabled ) {
417
- if ( data . is_sphinx_builder ( ) ) {
418
- attach_elastic_search_query_sphinx ( data ) ;
419
- } else {
420
- // MkDocs projects should have this flag explicitly for now.
421
- if ( data . features && ! data . features . docsearch_disabled ) {
422
- attach_elastic_search_query_mkdocs ( data ) ;
423
- }
424
- }
418
+ if ( data . is_sphinx_builder ( ) ) {
419
+ // Check for disabled server side search for sphinx
420
+ // happens inside the function, because we still need to call Search.init().
421
+ attach_elastic_search_query_sphinx ( data ) ;
422
+ }
423
+ // MkDocs projects should have this flag explicitly for now.
424
+ else if ( data . features && ! data . features . docsearch_disabled ) {
425
+ attach_elastic_search_query_mkdocs ( data ) ;
426
+ } else {
427
+ console . log ( 'Server side search is disabled.' ) ;
425
428
}
426
429
}
427
430
0 commit comments