useSearch
The hook for searching your data and applying selections

Basic Example

1
import { useSearch } from "@motor-js/engine"
2
3
const Search = () => {
4
5
const [options, setOptions] = useState([]);
6
const [searchValue, setSearchValue] = useState("");
7
const [qCount, setQCount] = useState(10);
8
const [qGroupItemCount, setQGroupOptions] = useState(10);
9
10
const {
11
groupResults,
12
flatResults,
13
groupselect,
14
flatSelect,
15
} = useSearch({
16
searchValue,
17
qCount,
18
qGroupItemCount
19
})
20
21
return (
22
<div></div>
23
);
24
25
};
Copied!

Search Options

The following options can be passed into the hook
  • searchValue: string
    • Required
    • The string you are searching your Qlik application for
  • qCount: number
    • Required
    • The maximum number of dimensions returned from the search results
  • qGroupItemCount: number
    • Required
    • The maximum number of values for each dimension returned from the search results

Search Properties

The following properties are returned from the hook
  • groupResults: array<groupResult>
    • An array of groupedResult objects, containing the search results grouped by dimension
  • flatResults: array<flatResult>
    • An array of flatResult objects, containing a flattened list of the search results. Each dimension value will be returned in a separate object
  • groupSelect: Function(id)
    • A function to apply selections against the Qlik engine
    • To be used with groupResults
    • Pass the id returned from the groupResult you wish to select. This will be the id of the dimension
    • Function will select all matching search items for that dimension
  • flatSelect: Function(dimension<string>, value<string>)
    • A function to apply selections against the Qlik engine
    • To be used with flatResults
    • Pass the dimension and value that you wish to select, both should be a string

groupResult Properties

The following properties are returned in each instance of the groupResults array
  • dimension: string
    • The dimension name returned from the search
  • value: Array<groupResultItems>
    • The an array of dimension values returned from the search

groupResultItem Properties

The following properties are returned in each instance of the groupResultItem array
  • qRanges
    • An object containing the character positions matched in the search result
  • qItem
    • The dimension value returned from the search

flatResult Properties

The following properties are returned in each instance of the flatResults array
  • dimension: string
    • The dimension name returned from the search
  • value: string
    • The dimension value returned from the search