{"id":13847014,"url":"https://github.com/nepsilon/search-query-parser","last_synced_at":"2026-02-19T23:35:24.696Z","repository":{"id":15755517,"uuid":"18494258","full_name":"nepsilon/search-query-parser","owner":"nepsilon","description":"A simple parser for advanced search query syntax","archived":false,"fork":false,"pushed_at":"2024-06-16T09:54:42.000Z","size":214,"stargazers_count":265,"open_issues_count":17,"forks_count":39,"subscribers_count":6,"default_branch":"master","last_synced_at":"2026-01-24T21:13:54.587Z","etag":null,"topics":["javascript","nodejs","search","search-interface"],"latest_commit_sha":null,"homepage":"https://www.npmjs.org/package/search-query-parser","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nepsilon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-04-06T16:56:01.000Z","updated_at":"2026-01-16T14:18:33.000Z","dependencies_parsed_at":"2024-01-13T16:25:40.106Z","dependency_job_id":"6429ae32-e578-4c6e-beba-6b5638950383","html_url":"https://github.com/nepsilon/search-query-parser","commit_stats":{"total_commits":92,"total_committers":16,"mean_commits":5.75,"dds":0.6195652173913043,"last_synced_commit":"8158d09c70b66168440e93ffabd720f4c8314c9b"},"previous_names":["retraceio/search-query-parser"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/nepsilon/search-query-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepsilon%2Fsearch-query-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepsilon%2Fsearch-query-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepsilon%2Fsearch-query-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepsilon%2Fsearch-query-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nepsilon","download_url":"https://codeload.github.com/nepsilon/search-query-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepsilon%2Fsearch-query-parser/sbom","scorecard":{"id":680050,"data":{"date":"2025-08-11","repo":{"name":"github.com/nepsilon/search-query-parser","commit":"8158d09c70b66168440e93ffabd720f4c8314c9b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Code-Review","score":2,"reason":"Found 4/18 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T22:49:02.802Z","repository_id":15755517,"created_at":"2025-08-21T22:49:02.802Z","updated_at":"2025-08-21T22:49:02.802Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29636575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","search","search-interface"],"created_at":"2024-08-04T18:00:52.413Z","updated_at":"2026-02-19T23:35:24.665Z","avatar_url":"https://github.com/nepsilon.png","language":"JavaScript","readme":"# Search Query Syntax Parser\n\n\u003e A simple parser for advanced search query syntax.\n\n[![Build Status](https://travis-ci.org/nepsilon/search-query-parser.svg?branch=master)](https://travis-ci.org/nepsilon/search-query-parser)\n\nIt parses a string like this:\n```\nfrom:hi@retrace.io,foo@gmail.com to:me subject:vacations date:1/10/2013-15/04/2014 photos\n```\n\nAnd turns it into an object like this:\n\n```javascript\n{\n  from: ['hi@retrace.io', 'foo@gmail.com'],\n  to: 'me',\n  subject: 'vacations',\n  date: {\n    from: '1/10/2013',\n    to: '15/04/2014'\n    },\n  text: 'photos',\n  offsets: \n   [ { keyword: 'from', value: 'hi@retrace.io,foo@gmail.com', offsetStart: 0, offsetEnd: 32 },\n     { keyword: 'to', value: 'me', offsetStart: 33, offsetEnd: 38 },\n     { keyword: 'subject', value: 'vacations', offsetStart: 39, offsetEnd: 56 },\n     { keyword: 'date', value: '1/10/2013-15/04/2014', offsetStart: 57, offsetEnd: 82 },\n     { text: 'photos', offsetStart: 83, offsetEnd: 89 } ]\n}\n```\n\n## Installation\n\n```shell\n$ npm install search-query-parser\n```\n\n## Usage\n\n```javascript\nvar searchQuery = require('search-query-parser');\n\nvar query = 'from:hi@retrace.io,foo@gmail.com to:me subject:vacations date:1/10/2013-15/04/2014 photos';\nvar options = {keywords: ['from', 'to', 'subject'], ranges: ['date']}\n\nvar searchQueryObj = searchQuery.parse(query, options);\n\n// searchQueryObj.from is now ['hi@retrace.io', 'foo@gmail.com']\n// searchQueryObj.to is now 'me'\n// searchQueryObj.date is now {from: '1/10/2013', to: '15/04/2014'}\n// searchQueryObj.text is now 'photos'\n```\n\nYou can configure what keywords and ranges the parser should accept with the options argument.\nIt accepts 5 values:\n* `keywords`, that can be separated by commas (,). Accepts an array of strings.\n* `ranges`, that can be separated by a hyphen (-). Accepts an array of strings.\n* `tokenize`, that controls the behaviour of text search terms. If set to `true`, non-keyword text terms are returned as an array of strings where each term in the array is a whitespace-separated word, or a multi-word term surrounded by single- or double-quotes.\n* `alwaysArray`, a boolean that controls the behaviour of the returned query. If set to `true`, all matched keywords would always be arrays instead of strings. If set to `false` they will be strings if matched a single value. Defaults to `false`.\n* `offsets`, a boolean that controls the behaviour of the returned query. If set to `true`, the query will contain the offsets object. If set to `false`, the query will not contain the offsets object. Defaults to `true`.\n\nIf no keywords or ranges are specified, or if none are present in the given search query, then `searchQuery.parse` will return a string if `tokenize` is false, or an array of strings under the key `text` if `tokenize` is true.\n\n```javascript\nvar searchQuery = require('search-query-parser');\n\nvar query = 'a query with \"just text\"';\nvar parsedQuery = searchQuery.parse(query);\n// parsedQuery is now 'a query with \"just text\"'\n\nvar options = {keywords: ['unused']};\nvar parsedQueryWithOptions = searchQuery.parse(query, options);\n// parsedQueryWithOptions is now 'a query with \"just text\"'\n\nvar options2 = {tokenize: true};\nvar parsedQueryWithTokens = searchQuery.parse(query, options2);\n// parsedQueryWithTokens is now: ['a', 'query', 'with', 'just text']\n```\n\nYou can also use exclusion syntax, like `-from:sep@foobar.io name:hello,world`. This also works with non-keyword text terms when `tokenize` is set to `true`. \n\n```javascript\n{\n  name: ['hello', 'world'],\n  exclude: {\n    from: ['sep@foobar.io']\n  }\n}\n```\n\nSometimes checking against whether a keyword holds string or not can be excessive and prone to errors; it's often easier to simply expect everything is an array even if it means doing 1-iteration loops often.\n\n```javascript\nvar searchQuery = require('search-query-parser');\n\nvar query = 'test:helloworld fun:yay,happy';\nvar options = {keywords: ['test', 'fun']};\nvar parsedQueryWithOptions = searchQuery.parse(query, options);\n// parsedQueryWithOptions is now:\n// {\n//   test: 'helloworld',\n//   fun: ['yay', 'happy']\n// }\n\nvar optionsAlwaysArray = {keywords: ['test', 'fun'], alwaysArray: true};\nvar parsedQueryWithOptions = searchQuery.parse(query, options);\n// parsedQueryWithOptions is now:\n// {\n//   test: ['helloworld'], //No need to check whether test is a string or not!\n//   fun: ['yay', 'happy']\n// }\n```\n\nThe offsets object could become pretty huge with long search queries which could be an unnecessary use of space if no functionality depends on it. It can simply be turned off using the option `offsets: false`.\n\nAnytime, you can go back and stringify the parsed search query. This could be handy if you would like to manipulate the parsed search query object.\n\n```javascript\nvar searchQuery = require('search-query-parser');\n\nvar query = 'from:hi@retrace.io,foo@gmail.com to:me subject:vacations date:1/10/2013-15/04/2014 photos';\nvar options = {keywords: ['from', 'to', 'subject'], ranges: ['date']}\n\nvar searchQueryObj = searchQuery.parse(query, options);\n\nsearchQueryObj.to = 'you';\nvar newQuery = searchQuery.stringify(query, options);\n\n// newQuery is now: photos from:hi@retrace.io,foo@gmail.com to:you subject:vacations date:1/10/2013-15/04/2014\n```\n\n## Typescript\n\nTypescript types are available for this library in the `docs` directory.\n[Browse type documentation here.](docs/README.md)\n\nDocumentation is generated using `node_modules/.bin/typedoc index.d.ts`\n\n## Testing\n\nThe 29 tests are written using the BDD testing framework should.js, and run with mocha.\n\nRun `npm install should` and `npm install -g mocha` to install them both.\n\nRun tests with `make test`.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnepsilon%2Fsearch-query-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnepsilon%2Fsearch-query-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnepsilon%2Fsearch-query-parser/lists"}