
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
elasticsearch-concise-query
Advanced tools
A highly configurable and syntactically concise Elasticsearch query builder
Elasticsearch Concise Query simplifies the process for querying an Elasticsearch index.
import { buildECQ } from 'elasticsearch-concise-query';
It is also available as a React higher-order component:
import { ECQ } from 'elasticsearch-concise-query';
...
const MyComponent = ({query, results}) => { ... }
export default ECQ(conciseQueries, config)(MyComponent)
See the examples
directory for more detailed example usage.
Using esConnect to access indexed Elasticsearch data for use in an application is as easy as passing a simple, single-depth object with search parameters and an optional configuration object into a function:
buildECQ({
match: { bike_type: 'road' },
range: { price: { lte: 600, gte: 1000 } },
enums: { frame: ['carbon', 'aluminum alloy'] },
multiField: [{ fields: ['description, keywords'], value: 'skinny tires' }]
}, configObj);
buildECQ
returns an Elasticsearch bool query object:
{
"query": {
"bool": {
"should": [
{
"match": {
"bike_type": "road"
}
},
{
"query": {
"range": {
"price": {
"lte": 600,
"gte": 1000
}
}
}
},
{
"query_string": {
"query": "carbon OR aluminum alloy",
"default_field": "frame",
"analyze_wildcard": false,
"fuzziness": 0
}
},
{
"multi_match": {
"query": "skinny tires",
"fields": [
"description, keywords"
]
}
}
],
"minimum_should_match": 4
}
},
"size": 5,
"sort": {
"price": {
"order": "asc"
}
}
}
A configuration object is passed as a second argument to buildECQ
:
KEY | VALUE TYPE | DESCRIPTION |
---|---|---|
index | String | The endpoint to send the query object to. |
[test] | Boolean | Runs esConnect in "test mode" (does not send a network request). |
[size] | Integer | Specify the maximum amount of results to return. Default: 10 |
[required] | Integer | Specify the minimum amount of queries a result should match (all if omitted). |
[sortBy] | String | Sort results by a specific date. |
To use with ElasticSearch's official Javascript client, elasticsearch.js, simply call buildESQuery
as follows in the object given to its search
method:
client.search({
index: 'myindex',
body: buildESQuery(query, config)
});
To use with ReactiveSearch, a React component library, simply pass a function that calls buildESQuery
as follows into the customQuery
prop. For example:
<DataSearch
...
customQuery={() => buildESQuery(query, config)}
/>
FAQs
A highly configurable and syntactically concise Elasticsearch query builder
The npm package elasticsearch-concise-query receives a total of 1 weekly downloads. As such, elasticsearch-concise-query popularity was classified as not popular.
We found that elasticsearch-concise-query demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.