search-ui
Search UI. Libraries for the fast development of modern, engaging search experiences.
Top Related Projects
⚡️ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
React + Vue Search UI for Elasticsearch & Opensearch. Compatible with Algolia's Instantsearch and Autocomplete components.
Next-Generation full text search library for Browser and Node.js
Quick Overview
Elastic's Search UI is a React-based library for building search experiences using Elasticsearch. It provides a set of customizable components and hooks that simplify the process of creating search interfaces, including features like faceted navigation, pagination, and sorting.
Pros
- Easy to integrate with Elasticsearch and other search engines
- Highly customizable components and theming options
- Built-in support for common search features (facets, pagination, sorting)
- Responsive design out of the box
Cons
- Limited documentation for advanced use cases
- Steeper learning curve for developers unfamiliar with React
- Some components may require additional styling for complex layouts
- Dependency on React ecosystem might be limiting for some projects
Code Examples
- Basic search setup:
import { SearchProvider, SearchBox, Results } from "@elastic/react-search-ui";
function App() {
return (
<SearchProvider config={config}>
<SearchBox />
<Results />
</SearchProvider>
);
}
- Adding facets:
import { Facet } from "@elastic/react-search-ui";
function SearchWithFacets() {
return (
<SearchProvider config={config}>
<SearchBox />
<Facet field="category" label="Category" />
<Results />
</SearchProvider>
);
}
- Custom result rendering:
import { withSearch } from "@elastic/react-search-ui";
function CustomResults({ results }) {
return (
<ul>
{results.map(result => (
<li key={result.id}>
<h3>{result.title}</h3>
<p>{result.description}</p>
</li>
))}
</ul>
);
}
export default withSearch(({ results }) => ({ results }))(CustomResults);
Getting Started
- Install the package:
npm install @elastic/react-search-ui @elastic/search-ui-elasticsearch-connector
- Set up a basic search configuration:
import { SearchProvider, SearchBox, Results } from "@elastic/react-search-ui";
import { ElasticsearchAPIConnector } from "@elastic/search-ui-elasticsearch-connector";
const connector = new ElasticsearchAPIConnector({
host: "http://localhost:9200",
index: "your_index_name"
});
const config = {
apiConnector: connector,
searchQuery: {
search_fields: {
title: {},
description: {}
},
result_fields: {
title: { raw: {} },
description: { raw: {} }
}
}
};
function App() {
return (
<SearchProvider config={config}>
<SearchBox />
<Results />
</SearchProvider>
);
}
This setup creates a basic search interface with a search box and results list, connected to your Elasticsearch instance.
Competitor Comparisons
⚡️ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
Pros of InstantSearch
- More comprehensive UI component library with a wider range of pre-built widgets
- Better support for multiple search engines, including Algolia, Elasticsearch, and custom backends
- Stronger TypeScript support and type definitions
Cons of InstantSearch
- Steeper learning curve due to more complex API and configuration options
- Heavier bundle size, which may impact performance for smaller applications
- Tighter coupling with Algolia's ecosystem, potentially making it less flexible for custom implementations
Code Comparison
InstantSearch:
import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
const App = () => (
<InstantSearch indexName="my_index" searchClient={searchClient}>
<SearchBox />
<Hits />
</InstantSearch>
);
Search UI:
import { SearchProvider, SearchBox, Results } from '@elastic/react-search-ui';
const App = () => (
<SearchProvider config={config}>
<SearchBox />
<Results />
</SearchProvider>
);
Both libraries offer similar high-level components for building search interfaces, but InstantSearch provides more granular control over individual widgets, while Search UI focuses on a simpler, more opinionated approach. InstantSearch's code tends to be more verbose due to its extensive configuration options, whereas Search UI aims for a more streamlined setup process.
React + Vue Search UI for Elasticsearch & Opensearch. Compatible with Algolia's Instantsearch and Autocomplete components.
Pros of Searchkit
- More flexible and customizable UI components
- Better support for Elasticsearch-specific features
- Easier integration with React-based applications
Cons of Searchkit
- Steeper learning curve for beginners
- Less comprehensive documentation compared to Search UI
- Smaller community and fewer third-party extensions
Code Comparison
Search UI:
import { SearchProvider, Results, SearchBox } from '@elastic/react-search-ui';
<SearchProvider config={config}>
<SearchBox />
<Results />
</SearchProvider>
Searchkit:
import { SearchkitProvider, SearchBox, Hits } from '@searchkit/react';
<SearchkitProvider config={config}>
<SearchBox />
<Hits />
</SearchkitProvider>
Both libraries offer similar high-level components for building search interfaces. However, Searchkit provides more granular control over UI elements and Elasticsearch-specific features, while Search UI offers a more straightforward setup for general search functionality.
Searchkit is better suited for developers who need deep customization and Elasticsearch-specific optimizations, whereas Search UI is ideal for those seeking a quick and easy implementation of search functionality across various search engines.
Next-Generation full text search library for Browser and Node.js
Pros of FlexSearch
- Lightweight and fast, with no dependencies
- Supports multiple languages and provides advanced search features
- Can be used in both browser and Node.js environments
Cons of FlexSearch
- Limited UI components and customization options
- Less integration with external search services like Elasticsearch
- Smaller community and fewer resources compared to Search UI
Code Comparison
FlexSearch:
import FlexSearch from 'flexsearch';
const index = new FlexSearch();
index.add(1, 'John Doe');
const results = index.search('John');
Search UI:
import { SearchProvider, SearchBox, Results } from '@elastic/react-search-ui';
<SearchProvider config={config}>
<SearchBox />
<Results />
</SearchProvider>
Summary
FlexSearch is a lightweight, fast, and versatile search library that can be used in various environments. It offers advanced search features and multi-language support. However, it lacks the extensive UI components and customization options provided by Search UI.
Search UI, on the other hand, offers a more comprehensive solution with pre-built UI components and better integration with external search services like Elasticsearch. It has a larger community and more resources available but may be overkill for simpler search implementations.
The choice between the two depends on the specific requirements of your project, such as the need for UI components, integration with external services, and the complexity of the search functionality required.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Elastic Search UI
A JavaScript library for the fast development of modern, engaging search experiences with Elastic. Get up and running quickly without re-inventing the wheel.
Check out the documentation to learn more about setting up and using Search UI.
Features ð
- You know, for search - Maintained by Elastic, the team behind Elasticsearch.
- Speedy Implementation - Build a complete search experience with a few lines of code.
- Customizable - Tune the components, markup, styles, and behaviors to your liking.
- Smart URLs - Searches, paging, filtering, and more, are captured in the URL for direct result linking.
- Flexible front-end - Not just for React. Use with any JavaScript library, even vanilla JavaScript.
- Flexible back-end - Use it with Elasticsearch, Elastic Enterprise Search, or any other search API.
Live demos ð
Connectors
- Elasticsearch
- â ï¸ DEPRECATED. Elastic App Search
- â ï¸ DEPRECATED. Elastic Workplace Search
- Elastic Site Search (Swiftype)
Examples
Get started
Installation
npm install @elastic/search-ui @elastic/react-search-ui @elastic/react-search-ui-views
# or
yarn add @elastic/search-ui @elastic/react-search-ui @elastic/react-search-ui-views
Tutorials
To quickly get started with Search UI, follow one of our tutorials:
- Search UI with Elasticsearch
- â ï¸ DEPRECATED. Search UI with Elastic App Search
- â ï¸ DEPRECATED. Search UI with Elastic Workplace Search
Contributing
We welcome contributors to the project. Follow our contributing guide to get started.
License ð
Thank you to all the contributors!
Top Related Projects
⚡️ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
React + Vue Search UI for Elasticsearch & Opensearch. Compatible with Algolia's Instantsearch and Autocomplete components.
Next-Generation full text search library for Browser and Node.js
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot