Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
algolia-search-builder
Advanced tools
Readme
A parser for having a structured way for querying algolia similar to well known ODMs or ORMS.
npm i algolia-search-builder
Currently Algolia supports string format only for filtering the search results, which doesn't seem very functional for making complex dynamic queries (probably by string concatenation), which requires you to memorize the built in algolia operators. Using the algolia query builder making dynamic filter queries is easier and similar to sequelize and mongoose.
const algoliaQueryBuilder = new AlgoliaQueryBuilder({
x:{lt:3, gte:1},
y:{between:[1,2]}
});
const filterQuery = algoliaQueryBuilder.exec(); // 'x < 3 AND x >= 1 AND y: 1 TO 2'
const results = algoliaIndex.search("str",{
filters: filterQuery
});
Checks if a field equals to the given value
{ x: { eq: 3 } }
Checks if a field is not equal to the given value
{ x: { ne: 3 } }
{ x: { gt: 3 } }
{ x: { gt: 3 } }
{ x: { lt: 3 } }
{ x: { lt: 3 } }
{ x: { between: [1,2] } }
{ x: { in: [1,2,3] } }
{ x: { not: { between:[ 1 , 2] } } }
{ or:
[
{ x: { eq:1 } },
{ y: { eq:2 } },
]
}
{ and:
[
{ x: { eq:1 } },
{ y: { eq:2 } },
]
}
// Field don't have to use operators they can be equal to a value right away
const algoliaQueryBuilder1 = new AlgoliaQueryBuilder({ x:3, y: "str" });
// An and can contain an or
const algoliaQueryBuilder2 = new AlgoliaQueryBuilder({
and:[
{x:3},
{or:[{y:4},{z:5}]}
]
});
// By default all the provided field queries are anded
const algoliaQueryBuilder2 = new AlgoliaQueryBuilder({
x:{
gt:3,
lt:6
}
}); // Return results with x greater than 3 and less than 6
The query builder validates the query after parsing and before returning the query string the limitations and constraints of the query builder are mostly related to the limitations given by algolia
To use _tags
for filtering just add the a custom field with name _tags
and pass it the value
{_tags:"published"}
FAQs
A query parser for algolia filters
The npm package algolia-search-builder receives a total of 2,141 weekly downloads. As such, algolia-search-builder popularity was classified as popular.
We found that algolia-search-builder 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.