search-ui
NOTE: This library is in an early Beta period, it is not yet recommended for production use
The "Headless Search UI" that serves as a foundation for the react-search-ui library.
If you are not using React, this library can be used in conjunction with
any other framework. Instead of working with components as you do in React, you simply work directly with state and actions. These are documented in the Search UI core section of the react-search-ui
README.
You'll get all of the benefit of Search UI, just with no view. The view is up to you.
Usage
npm install --save @elastic/search-ui
import { SearchDriver } from "@elastic/search-ui";
import AppSearchAPIConnector from "@elastic/search-ui-app-search-connector";
const connector = new AppSearchAPIConnector({
searchKey: "search-soaewu2ye6uc45dr8mcd54v8",
engineName: "national-parks-demo",
hostIdentifier: "host-2376rb"
});
const config = {
apiConnector: connector
};
const driver = new SearchDriver(config);
driver.subscribeToStateChanges(state =>
console.log(`Received ${state.totalResults} results for your search!`)
);
driver.getActions().setSearchTerm("canyon");
Configuration
All configuration is documented in the Search UI Configuration section
of the react-search-ui
README.
SearchDriver Usage
Methods
method | params | return | description |
---|
subscribeToStateChanges | function | | Function to execute when state changes. ex.
(state) => {} |
getActions | | ObjectActions | All available actions. |
getState | | State | Current state. |