{"_id":"@testlio/cloudsearch-query-builder","_rev":"40-b73a7eb99950c54d7fa5209bd05ea8d9","name":"@testlio/cloudsearch-query-builder","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@testlio/cloudsearch-query-builder","version":"1.0.0","keywords":["cloudsearch","query"],"author":{"name":"dev@testlio.com"},"license":"ISC","_id":"@testlio/cloudsearch-query-builder@1.0.0","maintainers":[{"name":"kaarelp","email":"kaarel.purde@testlio.com"}],"dist":{"shasum":"54d66c277e436bc40276dafc25fae0a4e21689b8","tarball":"https://registry.npmjs.org/@testlio/cloudsearch-query-builder/-/cloudsearch-query-builder-1.0.0.tgz","integrity":"sha512-72M5zr3S3OVqDZkuirPchata1FFE177kOvAtNE9mEylE4vIqhXZmz4efnEnE931LlRDPPXXuhOIfBq/bAswceQ==","signatures":[{"sig":"MEYCIQDzWsSrV18KisDth4tRpRPRJfUbZusQj9bmR4DHxCVTDwIhANR+PeHBcFF4JjNndmUzFLPGDeA5Ry80FqUxEZHtcAAa","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"54d66c277e436bc40276dafc25fae0a4e21689b8","gitHead":"b9dc552a8fa1cf4985ecf4e2cea14786b89aa488","scripts":{"lint":"eslint .","test":"mocha"},"_npmUser":{"name":"kaarelp","email":"kaarel.purde@testlio.com"},"_npmVersion":"3.3.12","description":"Builds string queries for cloudsearch","directories":{},"_nodeVersion":"5.4.1","devDependencies":{"mocha":"^2.4.5","eslint":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cloudsearch-query-builder-1.0.0.tgz_1457607676567_0.4082968726288527","host":"packages-13-west.internal.npmjs.com"}},"1.0.1":{"name":"@testlio/cloudsearch-query-builder","version":"1.0.1","keywords":["cloudsearch","query"],"author":{"name":"dev@testlio.com"},"license":"ISC","_id":"@testlio/cloudsearch-query-builder@1.0.1","maintainers":[{"name":"batweasel","email":"virgo@testlio.com"},{"name":"escane","email":"escane@gmail.com"},{"name":"georgetestlio","email":"george@testlio.com"},{"name":"henri","email":"henri@testlio.com"},{"name":"jekaterina","email":"jekaterina@testlio.com"},{"name":"kaarelkk","email":"kaarelkk@gmail.com"},{"name":"kaarelp","email":"kaarel.purde@testlio.com"},{"name":"kirstein","email":"mikk@kolmas.org"},{"name":"kschotter","email":"kairi@testlio.com"},{"name":"martinraag","email":"martin@testlio.com"},{"name":"mkruustu","email":"marko@testlio.com"},{"name":"rasmus-testlio","email":"rasmus@testlio.com"},{"name":"testlio-ci","email":"martin+npmjs@testlio.com"},{"name":"valdo","email":"valdo@testlio.com"}],"dist":{"shasum":"bf314fe61bbf93545c05752dc8e30d63b1328a9f","tarball":"https://registry.npmjs.org/@testlio/cloudsearch-query-builder/-/cloudsearch-query-builder-1.0.1.tgz","integrity":"sha512-BZZG9Mp+TVq/MofDqykCPzeeYRc3bPFhOBUGF2tZCkd+2AQNvfgEEXjd36mDjT2mjgcy8zP9AhY8V2GGocIxNQ==","signatures":[{"sig":"MEQCIAINzUewBeTVW+X+RdjlIebYUK1d6XFrmpTZMfiAmGsEAiAIWNT5EJ7Sz3WtIsC5pYw7AlYtQeYRjsUoVIMI5oqN9g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"bf314fe61bbf93545c05752dc8e30d63b1328a9f","gitHead":"f12827f0c0bed0078cc2c3d24f40654e11359b43","scripts":{"lint":"eslint .","test":"mocha","preversion":"npm run lint && npm run test"},"_npmUser":{"name":"testlio-ci","email":"martin+npmjs@testlio.com"},"_npmVersion":"3.6.0","description":"Builds string queries for cloudsearch","directories":{},"_nodeVersion":"5.7.0","devDependencies":{"mocha":"^2.4.5","eslint":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cloudsearch-query-builder-1.0.1.tgz_1457718743359_0.7476142863743007","host":"packages-13-west.internal.npmjs.com"}},"1.0.2":{"name":"@testlio/cloudsearch-query-builder","version":"1.0.2","keywords":["cloudsearch","query","builder","testlio","aws"],"author":{"name":"dev@testlio.com"},"license":"ISC","_id":"@testlio/cloudsearch-query-builder@1.0.2","maintainers":[{"name":"batweasel","email":"virgo@testlio.com"},{"name":"escane","email":"escane@gmail.com"},{"name":"georgetestlio","email":"george@testlio.com"},{"name":"henri","email":"henri@testlio.com"},{"name":"jekaterina","email":"jekaterina@testlio.com"},{"name":"kaarelkk","email":"kaarelkk@gmail.com"},{"name":"kaarelp","email":"kaarel.purde@testlio.com"},{"name":"kirstein","email":"mikk@kolmas.org"},{"name":"kschotter","email":"kairi@testlio.com"},{"name":"martinraag","email":"martin@testlio.com"},{"name":"mkruustu","email":"marko@testlio.com"},{"name":"rasmus-testlio","email":"rasmus@testlio.com"},{"name":"testlio-ci","email":"martin+npmjs@testlio.com"},{"name":"valdo","email":"valdo@testlio.com"}],"dist":{"shasum":"cf811628c8515ecb79b57c6257642e7e6d024566","tarball":"https://registry.npmjs.org/@testlio/cloudsearch-query-builder/-/cloudsearch-query-builder-1.0.2.tgz","integrity":"sha512-2wlXVuGUEDCIMRdKAKgYtlbqXddCatCSMbpTMG26K/IhlGBW7mxJnXTBw7zvY6z7sFAEdUUlWbkzMjF3JGANCw==","signatures":[{"sig":"MEQCIEDu1VLLwwyeeHBe/a06vXvFyzITOCpKWh25VR2t0bphAiAL4oL2BBUPYCNH1BHHCQNbjJSO9+z9ng97PkDo9DP8Cw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"cf811628c8515ecb79b57c6257642e7e6d024566","gitHead":"58a8cf45303360723c8258e06d0b438828e4c976","scripts":{"lint":"eslint .","test":"mocha","preversion":"npm run lint && npm run test"},"_npmUser":{"name":"testlio-ci","email":"martin+npmjs@testlio.com"},"_npmVersion":"3.6.0","description":"Builds string queries for cloudsearch","directories":{},"_nodeVersion":"5.7.0","devDependencies":{"mocha":"^2.4.5","eslint":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cloudsearch-query-builder-1.0.2.tgz_1458031585965_0.38952450826764107","host":"packages-12-west.internal.npmjs.com"}},"1.0.3":{"name":"@testlio/cloudsearch-query-builder","version":"1.0.3","keywords":["cloudsearch","query","builder","testlio","aws"],"author":{"name":"dev@testlio.com"},"license":"ISC","_id":"@testlio/cloudsearch-query-builder@1.0.3","maintainers":[{"name":"batweasel","email":"virgo@testlio.com"},{"name":"escane","email":"escane@gmail.com"},{"name":"georgetestlio","email":"george@testlio.com"},{"name":"henri","email":"henri@testlio.com"},{"name":"jekaterina","email":"jekaterina@testlio.com"},{"name":"kaarelkk","email":"kaarelkk@gmail.com"},{"name":"kaarelp","email":"kaarel.purde@testlio.com"},{"name":"kirstein","email":"mikk@kolmas.org"},{"name":"kschotter","email":"kairi@testlio.com"},{"name":"martinraag","email":"martin@testlio.com"},{"name":"mkruustu","email":"marko@testlio.com"},{"name":"rasmus-testlio","email":"rasmus@testlio.com"},{"name":"testlio-ci","email":"martin+npmjs@testlio.com"},{"name":"valdo","email":"valdo@testlio.com"}],"dist":{"shasum":"ce48ca7d7799d6e51c98ad5265d0400e6ac210ae","tarball":"https://registry.npmjs.org/@testlio/cloudsearch-query-builder/-/cloudsearch-query-builder-1.0.3.tgz","integrity":"sha512-NtnS9Q0bp+IjvYcSsCn4uq4y1o0OjABxn6wzcJvgmi723LT3jfRaue8GCpGwhG5qfhGVR+tfp69TG/kipv/ZGA==","signatures":[{"sig":"MEQCIEdLtRnupPTMcmEHKJiRSEBwNjdunlnKmkxEwaR1Gd6gAiA4d7CILpEvoMPBOfufoTpGFGA5z+Dy2iVOQ+EoWTgPsw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"ce48ca7d7799d6e51c98ad5265d0400e6ac210ae","gitHead":"1b45452a7f052976d492a5dff18a037e7c15b746","scripts":{"lint":"eslint .","test":"mocha","preversion":"npm run lint && npm run test"},"_npmUser":{"name":"testlio-ci","email":"martin+npmjs@testlio.com"},"_npmVersion":"3.6.0","description":"Builds string queries for cloudsearch","directories":{},"_nodeVersion":"5.7.0","devDependencies":{"mocha":"^2.4.5","eslint":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cloudsearch-query-builder-1.0.3.tgz_1458287497543_0.10147843440063298","host":"packages-12-west.internal.npmjs.com"}}},"time":{"created":"2016-03-10T11:01:18.783Z","modified":"2026-08-28T14:10:46.651Z","1.0.0":"2016-03-10T11:01:18.783Z","1.0.1":"2016-03-11T17:52:25.606Z","1.0.2":"2016-03-15T08:46:26.426Z","1.0.3":"2016-03-18T07:51:40.091Z"},"author":{"name":"dev@testlio.com"},"license":"ISC","keywords":["cloudsearch","query","builder","testlio","aws"],"description":"Builds string queries for cloudsearch","maintainers":[{"email":"dev-services@testlio.com","name":"testlio-ci"},{"email":"hello@roope.sh","name":"roopeshvs"},{"email":"viraj.premaratne@testlio.com","name":"viraj.premaratne"}],"readme":"# CloudSearch Query Builder\n\n[![Circle CI](https://img.shields.io/circleci/project/Testlio/cloudsearch-query-builder/master.svg)](https://circleci.com/gh/Testlio/cloudsearch-query-builder/tree/master) [![NPM Package](https://img.shields.io/npm/v/@testlio/cloudsearch-query-builder.svg)](https://www.npmjs.com/package/@testlio/cloudsearch-query-builder)\n\nAWS CloudSearch supports searching over data/documents by using query strings, these query strings can contain compound query in a specific format/syntax. While this syntax is [well documented](http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-compound-queries.html), creating this string in code can be error-prone. This is where query builder comes in, allowing queries to be built using a more functional approach, and ensuring the resulting string is in the correct format.\n\n## Installation\n\n```\nnpm install @testlio/cloudsearch-query-builder\n```\n\n## Getting Started\n\nQuery builder mirrors the available operators, [listed here](http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-compound-queries.html), as functions that take arguments and produce a string. All of these functions are well-documented in the code itself, thus a few example cases here should do the trick.\n\n```js\n// Query for all Star Wars films released before the year 2000\nbuilder.and([builder.phrase('star wars', 'title'), builder.range('year', undefined, 2000)]);\n// -> (and (phrase field=star wars 'title') (range field=year {,2000]))\n```\n\n```js\n// Query for all Star Wars films, boosting those released before year 2000\nbuilder.and([builder.phrase('star wars', 'title'), builder.or([builder.range('year', undefined, 2000, { boost: 4 }), builder.range('year', 2000)])]);\n// -> (and (phrase field=title 'star wars') (or (range field=year boost=4 {,2000]) (range field=year [2000,})))\n```\n\n```js\n// Query for all Star Wars films that Harrison Ford stars in\nbuilder.and([builder.term('Harrison Ford', 'actors'), builder.phrase('star wars', 'title')]);\n// -> (and (term field=actors 'Harrison Ford') (phrase field=title 'star wars'))\n```\n\nWith certain operators, you can also omit the field to search over all textual fields, for example:\n\n```js\n// Search for all films that contain term 'star' in any of their textual fields\nbuilder.term('star');\n// -> (term 'star')\n\n// Search for all films released after year 2000 that mention Harrison Ford\nbuilder.and([builder.phrase('Harrison Ford'), builder.range('year', 2000)]);\n// -> (and (term 'star') (range field=year [2000,}))\n```\n\nThe full API is documented inline, you can go over it [here](index.js).\n\n## Interfacing with AWS SDK\n\nThe resulting string from query builder should be passed along to the `search` function of [CloudSearchDomain in AWS SDK for Node.js](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudSearchDomain.html#search-property). It is important to note that all strings that query builder returns rely on the `queryParser` parameter to be set to `structured`.\n\n```js\n// Obtain CloudSearchDomain, possibly via CloudSearch.describeDomains()\nconst cloudSearchDomain = ...;\nconst builder = require('@testlio/cloudsearch-query-builder');\n\n// Create a query as explained above\nconst query = builder.and([builder.phrase('star wars', 'title'), builder.range('year', undefined, 2000)]);\n\n// Conduct the search\ncloudSearchDomain.search({\n    query: query,\n    queryParser: 'structured'\n}, function(err, data) {\n    // Handle the results\n});\n```\n\n**NOTE:** Because of the CloudSearch limitations, query builder removes double quotes from the search parameters.\n\n## Contributing\n\nContributions to cloudsearch-query-builder are very welcome! Please make sure to follow the [Contribution Guidelines](.github/CONTRIBUTING.MD). Areas that you could help out with include, but are not limited to:\n\n1. Supporting other query parsers\n2. Increasing test coverage\n3. Documentation and providing further examples\n","readmeFilename":"README.md"}