diff --git a/omnibus/files/server-ctl-cookbooks/infra-server/templates/default/oc_erchef.config.erb b/omnibus/files/server-ctl-cookbooks/infra-server/templates/default/oc_erchef.config.erb index c020307c0f..ef130af34e 100755 --- a/omnibus/files/server-ctl-cookbooks/infra-server/templates/default/oc_erchef.config.erb +++ b/omnibus/files/server-ctl-cookbooks/infra-server/templates/default/oc_erchef.config.erb @@ -194,6 +194,7 @@ {timeout, <%= @solr_timeout %>}, {init_count, <%= @solr_http_init_count %>}, {max_count, <%= @solr_http_max_count %>}, + {track_total_hits,true}, {cull_interval, <%= @solr_http_cull_interval %>}, {max_age, <%= @solr_http_max_age %>}, {max_connection_duration, <%= @solr_http_max_connection_duration %>}, diff --git a/src/oc_erchef/apps/chef_index/src/chef_index_query.erl b/src/oc_erchef/apps/chef_index/src/chef_index_query.erl index 3b68518fe8..8f0b9e07ce 100644 --- a/src/oc_erchef/apps/chef_index/src/chef_index_query.erl +++ b/src/oc_erchef/apps/chef_index/src/chef_index_query.erl @@ -30,6 +30,7 @@ from_params(Provider, ObjType, QueryString, Start, Rows) -> search_provider = Provider, start = decode({nonneg_int, "start"}, Start, 0), rows = decode({nonneg_int, "rows"}, Rows, 1000), + track_total_hits = envy:get(chef_index, track_total_hits, false, boolean), sort = "X_CHEF_id_CHEF_X asc", index = index_type(ObjType)}. diff --git a/src/oc_erchef/apps/chef_index/src/chef_opensearch.erl b/src/oc_erchef/apps/chef_index/src/chef_opensearch.erl index 3d6eec7bc3..667bbea349 100644 --- a/src/oc_erchef/apps/chef_index/src/chef_opensearch.erl +++ b/src/oc_erchef/apps/chef_index/src/chef_opensearch.erl @@ -103,6 +103,7 @@ query_body(#chef_solr_query{ query_string = Query, filter_query = undefined, start = Start, + track_total_hits = TrackTotalHits, rows = Rows}) -> jiffy:encode({[{fields_tag(), <<"_id">>}, {<<"from">>, Start}, @@ -118,6 +119,7 @@ query_body(#chef_solr_query{ jiffy:encode({[{ fields_tag(), <<"_id">>}, {<<"from">>, Start}, {<<"size">>, Rows}, + {<<"track_total_hits">>,TrackTotalHits}, {<<"sort">>, [{[{<<"X_CHEF_id_CHEF_X">>, {[{<<"order">>, <<"asc">>}]}}]}]}, {<<"query">>, {[ {<<"bool">>,{[ diff --git a/src/oc_erchef/habitat/config/sys.config b/src/oc_erchef/habitat/config/sys.config index 9d75dc2cd3..f2cb66c66e 100644 --- a/src/oc_erchef/habitat/config/sys.config +++ b/src/oc_erchef/habitat/config/sys.config @@ -173,6 +173,7 @@ {search_batch_max_wait, 10}, {reindex_sleep_min_ms, 500}, {reindex_sleep_max_ms, 2000}, + {track_total_hits,true}, {reindex_item_retries, 3}, {solr_elasticsearch_major_version, 5}, {solr_service, [ diff --git a/src/oc_erchef/include/chef_solr.hrl b/src/oc_erchef/include/chef_solr.hrl index f926962cd9..45ba44efdf 100644 --- a/src/oc_erchef/include/chef_solr.hrl +++ b/src/oc_erchef/include/chef_solr.hrl @@ -21,6 +21,7 @@ search_provider = solr :: 'solr' | 'elasticsearch' | 'opensearch', start :: integer() | undefined, rows :: integer() | undefined, + track_total_hits :: boolean(), sort :: string() | undefined, index :: 'node' | 'role'