{"id":34134534,"url":"https://github.com/ecromaneli/search-engine","last_synced_at":"2026-04-01T23:37:42.569Z","repository":{"id":290907115,"uuid":"975462648","full_name":"ECRomaneli/Search-Engine","owner":"ECRomaneli","description":"A lightweight, powerful object search engine for JavaScript with advanced query syntax","archived":false,"fork":false,"pushed_at":"2025-07-02T01:14:25.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-17T12:44:03.530Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ECRomaneli.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":"2025-04-30T10:59:52.000Z","updated_at":"2025-07-02T01:14:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ff8c180-0b8e-4c35-ad61-de5724b1aab9","html_url":"https://github.com/ECRomaneli/Search-Engine","commit_stats":null,"previous_names":["ecromaneli/search-engine"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/ECRomaneli/Search-Engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FSearch-Engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FSearch-Engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FSearch-Engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FSearch-Engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ECRomaneli","download_url":"https://codeload.github.com/ECRomaneli/Search-Engine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ECRomaneli%2FSearch-Engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: 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":[],"created_at":"2025-12-15T01:25:34.587Z","updated_at":"2026-04-01T23:37:42.564Z","avatar_url":"https://github.com/ECRomaneli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Search-Engine\n\nA lightweight, powerful object search engine for JavaScript with advanced query syntax.\n\n\u003cp\u003e\n\u003ca href=\"https://github.com/ECRomaneli/Search-Engine/tags\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/ecromaneli/Search-Engine?label=version\u0026sort=semver\" alt=\"Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ECRomaneli/Search-Engine/commits/master\"\u003e\u003cimg src=\"https://img.shields.io/github/last-commit/ecromaneli/Search-Engine\" alt=\"Last Commit\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ECRomaneli/Search-Engine/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/ecromaneli/Search-Engine\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ECRomaneli/Search-Engine/issues\"\u003e\u003cimg src=\"https://img.shields.io/badge/contributions-welcome-brightgreen.svg\" alt=\"Contributions Welcome\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\n```bash\nnpm install @ecromaneli/search-engine\n``` \n\n## Features\n\n- Powerful query language with boolean operators (AND/OR)\n- Field-specific searches\n- Support for wildcards and regex pattern matching\n- Numeric range searches\n- Logical negation of search terms\n- Nested property searching\n- Logical grouping with parentheses\n- Customizable search options\n- Zero dependencies\n\n## Basic Usage\n\n```javascript\nconst SearchEngine = require('@ecromaneli/search-engine')\n\nconst users = [\n  { id: 1, name: 'John Doe', age: 28, tags: ['developer', 'javascript'] },\n  { id: 2, name: 'Jane Smith', age: 34, tags: ['designer', 'ui/ux'] },\n  { id: 3, name: 'Bob Johnson', age: 45, tags: ['manager', 'finance'] }\n]\n\nconst result = SearchEngine.search(users, 'name: john')\nconsole.log(result)\n```\n\n## Using the SearchEngine Constructor\n\nYou can create a `SearchEngine` instance with specific options that will be used for all searches:\n\n```javascript\nconst engine = new SearchEngine({\n  excludeKeys: ['name', 'tags'],\n  allowNumericString: false,\n  allowKeyValueMatching: true,\n  matchChildKeysAsValues: false,\n  maxLevels: 5\n})\n\nconst results = engine.search(users, 'age~: 25-35')\nconsole.log(results)\n```\n\n## Search Options\n\nThe `SearchOptions` object allows you to customize the behavior of the search engine. Below is a table explaining each option:\n\n| Option                   | Type       | Default | Description                                                                                     |\n|--------------------------|------------|---------|-------------------------------------------------------------------------------------------------|\n| `excludeKeys`            | `string[]` | `[]`    | Array of keys to exclude from search. Useful for excluding sensitive data.                      |\n| `allowNumericString`     | `boolean`  | `true`  | Controls whether string values that can be parsed as numbers are used in range searches.        |\n| `allowKeyValueMatching`  | `boolean`  | `true`  | When enabled, unquoted terms without a field/value separator match both field names and values. |\n| `matchChildKeysAsValues` | `boolean`  | `false` | When enabled, after finding a matching key, also looks for the value in child object keys.      |\n| `maxLevels`              | `number`   | unlimited | Maximum levels of nested objects to search through. Useful to avoid infinite loops in deeply nested or circular data. |\n\n### Notes\n- The `maxLevels` option can be set to limit how deep the search will go into nested objects. This is especially useful for large or circular data structures.\n\n### Differences Between Options\n\n- **`allowNumericString`**:\n  - When `true`, strings like `\"123\"` will be treated as numbers in range searches.\n  - When `false`, only actual numbers will be considered for range searches.\n\n- **`allowKeyValueMatching`**:\n  - When `true`, a query like `admin` will match both `{ admin: \"value\" }` and `{ key: \"admin\" }`.\n  - When `false`, it will only match field names or values explicitly.\n\n- **`matchChildKeysAsValues`**:\n  - When `true`, a query like `foo:bar` will match both `{ foo: \"bar\" }` and `{foo: { bar: \"value\" }}`.\n  - When `false`, it will only match `{ foo: \"bar\" }`.\n\n## Query Syntax Reference\n\n### Basic Queries\n\n- `foo` - Search for objects having a field or value `foo`.\n- `\"value\"` - Search for `\"value\"` in any field.\n- `field: value` - Search for `value` in the specific `field`.\n\n### Specialized Searches\n\n- `field*: pattern` - Regex pattern match on field.\n- `field~: min-max` - Numeric range search.\n- `field~: 10-` - Numbers greater than or equal to 10.\n- `field~: -20` - Numbers less than or equal to 20.\n\n### \"Is / Is Not\" Operators\n\n- `field is value` - Search for objects where `field` is exactly `value`.\n- `field is not value` - Search for objects where `field` is not `value`.\n\nWhere `value` must be one of the following:\n- A boolean (`true` or `false`)\n- `null`\n- `undefined` (or `undef`)\n- `blank` (empty strings)\n- `empty` (empty arrays)\n\n### Boolean Operators\n\n- `term1 and term2` - Both terms must match.\n- `term1 or term2` - Either term must match.\n\n### Negation and Grouping\n\n- `not term` - Term must not match.\n- `not (term1 or term2)` - Group negation (neither term1 nor term2 should match).\n- `(term1 or term2) and term3` - Logical grouping with parentheses.\n\n## API Reference\n\n### Static Methods\n\n#### `SearchEngine.search(objList, queryStr, options)`\n\n- **`objList`** (`Array`): Array of objects to search through.\n- **`queryStr`** (`String`): Query string following the syntax described above.\n- **`options`** (`Object`, optional): Search options object.\n- **Returns** (`Array`): Array of matching objects.\n\n### Instance Methods\n\nTo store the options, use the constructor below:\n\n#### `new SearchEngine(options)`\n\n- **`options`** (`Object`, optional): Search options object (see Options table).\n- **Returns** (`SearchEngine`): A new `SearchEngine` instance with the specified options.\n\n#### `searchInstance.search(objList, queryStr)`\n\n- **`objList`** (`Array`): Array of objects to search through.\n- **`queryStr`** (`String`): Query string following the syntax described above.\n- **Returns** (`Array`): Array of matching objects with the instance's options applied.\n\n## Performance Tips\n\n- For large datasets, consider disabling `allowNumericString` if you don't need string-to-number conversion.\n- Set `matchChildKeysAsValues: false` (default) unless you specifically need to match object keys as values.\n- Use `excludeKeys` to skip searching in fields that are never relevant to your searches.\n- For repeated searches with the same options, create a `SearchEngine` instance instead of using the static method.\n- Limit `maxLevels` if you have deeply nested data to avoid performance issues.\n\n## Examples and Advanced Usage\n\nFor a comprehensive set of usage examples covering all search engine features, refer to our test suite:\n\n[View Test Examples](test/index.test.js)\n\nThe test file includes examples of:\n- Complex nested property searching\n- Array item searching\n- Logical grouping with parentheses\n- De Morgan's law transformations\n- Complex boolean expressions\n- Excluded keys functionality\n- Range searches with various configurations\n- Quoted values with special characters\n- Edge cases and error handling\n\nThese examples serve as excellent reference implementations when building advanced search queries.\n\n## Author\n\nCreated by Emerson Capuchi Romaneli (@ECRomaneli).\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecromaneli%2Fsearch-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecromaneli%2Fsearch-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecromaneli%2Fsearch-engine/lists"}