export function getSearchString()

in server/utils/helpers.ts [58:71]


export function getSearchString(terms?: string[], indices?: string[], dataStreams?: string[], showDataStreams: boolean = true): string {
  // Terms are searched with a wildcard around them.
  const searchTerms = terms ? `*${_.castArray(terms).join("*,*")}*` : "";

  // Indices and data streams are searched with an exact match.
  const searchIndices = indices ? _.castArray(indices).join(",") : "";
  const searchDataStreams = dataStreams ? _.castArray(dataStreams).join(",") : "";

  // The overall search string is a combination of terms, indices, and data streams.
  // If the search string is blank, then '*' is used to match everything.
  const resolved = [searchTerms, searchIndices, searchDataStreams].filter((value) => value !== "").join(",") || "*";
  // We don't want to fetch managed datastream indices if there are not selected by caller.
  return showDataStreams ? resolved : resolved + " -.ds"
}