![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@searchkit/api
Advanced tools
Readme
Searchkit is an open source library which helps you build a great search experience with Elasticsearch.
Works with React, Vue, Angular, and more.
Website | Demos | Documentation | Discord
Searchkit to simplify using Elasticsearch for Search:
import Searchkit from "searchkit"
import Client from '@searchkit/instantsearch-client'
// import your InstantSearch components
import { InstantSearch, SearchBox, Hits, RefinementList, Pagination, NumericMenu } from 'react-instantsearch-dom';
const sk = new Searchkit({
connection: {
host: 'http://localhost:9200'
},
search_settings: {
search_attributes: [{ field: 'title', weight: 3 }, 'actors', 'plot'],
result_attributes: ['title', 'actors', 'poster', 'plot'],
highlight_attributes: ['title'],
facet_attributes: [
{ attribute: 'actors', field: 'actors.keyword', type: 'string' },
{ attribute: 'imdbrating', type: 'numeric', field: 'imdbrating' }
]
}
})
const searchClient = Client(searchkitClient);
const App = () => (
<InstantSearch
indexName="imdb_movies"
searchClient={searchClient}
>
<SearchBox />
<div className="left-panel">
<RefinementList attribute="actors" searchable={true} limit={10} />
<NumericMenu
attribute="imdbrating"
items={[
{ label: '5 - 7', start: 5, end: 7 },
{ label: '7 - 9', start: 7, end: 9 },
{ label: '>= 9', start: 9 },
]}
/>
</div>
<div className="right-panel">
<Hits />
<Pagination />
</div>
</InstantSearch>
}
In above example, we are calling Elasticsearch directly from the browser. This is not recommended for production use. Instead, you should use the Searchkit API to proxy requests to Elasticsearch. With Searchkit, you can do this in a few lines of code.
import Searchkit from "searchkit"
import Client from '@searchkit/instantsearch-client'
// import your InstantSearch components
import { InstantSearch, SearchBox, Hits, RefinementList, Pagination, NumericMenu } from 'react-instantsearch-dom';
const searchClient = Client({
url: "/api/search",
});
const App = () => (
<InstantSearch
indexName="imdb_movies"
searchClient={searchClient}
>
<SearchBox />
<div className="left-panel">
<RefinementList attribute="actors" searchable={true} limit={10} />
<NumericMenu
attribute="imdbrating"
items={[
{ label: '5 - 7', start: 5, end: 7 },
{ label: '7 - 9', start: 7, end: 9 },
{ label: '>= 9', start: 9 },
]}
/>
</div>
<div className="right-panel">
<Hits />
<Pagination />
</div>
</InstantSearch>
}
Example below using Next.js API Routes. You can also use Cloudflare Workers or Vercel Edge Functions, or any other Node.js server.
import Client from '@searchkit/api'
import { NextApiRequest, NextApiResponse } from 'next'
const client = Client(
{
connection: {
host: 'http://localhost:9200'
},
search_settings: {
search_attributes: [{ field: 'title', weight: 3 }, 'actors', 'plot'],
result_attributes: ['title', 'actors', 'poster', 'plot'],
highlight_attributes: ['title'],
facet_attributes: [
{ attribute: 'actors', field: 'actors.keyword', type: 'string' },
{ attribute: 'imdbrating', type: 'numeric', field: 'imdbrating' }
]
}
},
{ debug: true }
)
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const results = await client.handleRequest(req.body)
res.send(results)
}
Query rules allows you to customize the behavior of the search experience. You can use query rules to boost or filter results, or to change the ranking of results, based on a set of conditions.
Below is an example of a query rule that boosts results for movies with Dan Aykroyd or Charlie Sheen, and filters results to only show movies if the query is the word "movie".
{
id: '1',
conditions: [
[
{
context: 'query',
value: 'movie',
match_type: 'exact'
}
]
],
actions: [
{
action: 'QueryBoost',
query: 'actors:"Dan Aykroyd" OR actors:"Charlie Sheen"',
weight: 2
},
{
action: 'QueryFilter',
query: 'type:"movie"'
}
]
}
FAQs
Node API for Searchkit. Transforms the instantsearch Search State into a query for Elasticsearch on Node.
The npm package @searchkit/api receives a total of 4,033 weekly downloads. As such, @searchkit/api popularity was classified as popular.
We found that @searchkit/api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.