{"id":27997637,"url":"https://github.com/itemsapi/elasticitems","last_synced_at":"2025-05-08T21:59:53.589Z","repository":{"id":18030659,"uuid":"83199683","full_name":"itemsapi/elasticitems","owner":"itemsapi","description":"Higher level client for Elasticsearch written in Node.js oriented on facets and simplicity","archived":false,"fork":false,"pushed_at":"2025-02-07T18:46:05.000Z","size":261,"stargazers_count":20,"open_issues_count":8,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-08T21:59:46.942Z","etag":null,"topics":["client","elasticsearch","facets","sorting"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itemsapi.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}},"created_at":"2017-02-26T10:13:57.000Z","updated_at":"2025-02-07T18:46:09.000Z","dependencies_parsed_at":"2022-08-07T10:15:17.350Z","dependency_job_id":null,"html_url":"https://github.com/itemsapi/elasticitems","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itemsapi%2Felasticitems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itemsapi%2Felasticitems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itemsapi%2Felasticitems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itemsapi%2Felasticitems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itemsapi","download_url":"https://codeload.github.com/itemsapi/elasticitems/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253154970,"owners_count":21862621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["client","elasticsearch","facets","sorting"],"created_at":"2025-05-08T21:59:52.967Z","updated_at":"2025-05-08T21:59:53.541Z","avatar_url":"https://github.com/itemsapi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ElasticItems\n\nElasticsearch 7.x client for JS with faceted search, custom features and simple interface\n\n## Features\n\n- faceted search\n- full text\n- pagination\n- sorting\n\n## Getting Started\n\n```bash\nnpm install elasticitems\n```\n\n```js\nconst elasticitems = require('elasticitems')(es_config, search_config);\nelasticitems.search()\n.then(result =\u003e {\n  console.log(result);\n})\n```\n\n## API\n\n### var elasticitems = ElasticItems(es_config, [search_config])\n\n#### `es_config`\n\nThe first `es_config` is elasticsearch configuration object and contains values like `host`, `index` or `type`.\n\n#### `search_config`\n\nResponsible for defining global configuration.\n\n  * **\u003ccode\u003eaggregations\u003c/code\u003e** filters configuration i.e. for `tags`, `actors`, `colors`, etc. Responsible for generating facets.\n\n  * **\u003ccode\u003esortings\u003c/code\u003e** you can configure different sortings like `tags_asc`, `tags_desc` with options and later use it with one key.\n\n### elasticitems.search(options, [search_config])\n\n#### `options`\n\n  * **\u003ccode\u003eper_page\u003c/code\u003e** amount of items per page.\n\n  * **\u003ccode\u003epage\u003c/code\u003e** page number - used for pagination.\n\n  * **\u003ccode\u003equery\u003c/code\u003e** used for full text search.\n\n  * **\u003ccode\u003eoperator\u003c/code\u003e** search operator `and` and `or` (default). It works with `query` parameter\n\n  * **\u003ccode\u003esort\u003c/code\u003e** used for sorting. one of `sortings` key\n  \n  * **\u003ccode\u003efilters\u003c/code\u003e** filtering items based on specific aggregations i.e. {tags: ['drama' , 'historical']}  \n\n  * **\u003ccode\u003equery_string\u003c/code\u003e** i.e. \"brand:Audi OR brand:Mercedes\"\n\n  * **\u003ccode\u003efacets_names\u003c/code\u003e** make faceted search only for specific fields i.e. ['tags', 'genres']\n\n  * **\u003ccode\u003efields\u003c/code\u003e** search only in specifc fields i.e. ['name', 'description']. Missing parameter means search in all fields\n\n  * **\u003ccode\u003eids\u003c/code\u003e** search by ids i.e. ['1', '2', '3']\n\n  * **\u003ccode\u003eexclude_ids\u003c/code\u003e** exclude ids from search i.e. ['1', '2', '3']\n\n### elasticitems.similar(id, options)\n\nShow similar items based on collaborative filtering\n\n#### `options`\n\n  * **\u003ccode\u003efields\u003c/code\u003e** i.e ['tags'].\n\n### elasticitems.aggregation(options)\n\nIt returns full list of filters for specific aggregation\n\n#### `options`\n\n  * **\u003ccode\u003ename\u003c/code\u003e** aggregation name\n\n  * **\u003ccode\u003eper_page\u003c/code\u003e** filters per page\n  \n  * **\u003ccode\u003esize\u003c/code\u003e** how much load into memory (for pagination)\n\n  * **\u003ccode\u003epage\u003c/code\u003e** page number\n  \n  * **\u003ccode\u003esort\u003c/code\u003e** responsible for sorting mechanism. It can be `_count` or `_term`\n\n  * **\u003ccode\u003eorder\u003c/code\u003e** responsible for an order. It can be `asc` or `desc`\n\n  * **\u003ccode\u003efilters\u003c/code\u003e** filter this aggregation through another aggregations (facets)\n\n  * **\u003ccode\u003eaggregation_query\u003c/code\u003e** used for quering filters. It's not full text search\n\n  * **\u003ccode\u003equery\u003c/code\u003e** search through items\n\n  * **\u003ccode\u003equery_string\u003c/code\u003e** search through items by query string i.e. (category:Garden and color:red)\n  \n### elasticitems.get(id)\n\nReturns found record otherwise throw an error\n\n### elasticitems.getBy(key, value)\n\nReturns record based on key and value \n\n### elasticitems.add(data, [options])\n\nAdd a new object into index. Provide your own `id` if you don't want it auto-generated\n\n### elasticitems.partialUpdate(id, data, [options])\n\nUpdates object in index\n\n### elasticitems.delete(id)\n\nDelete object from index\n\n### Notes\n\n- Full text search does not work on `keyword` type because this type is not tokenized. `keyword` type is great for faceted fields\n\n## Tests\n\n```\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitemsapi%2Felasticitems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitemsapi%2Felasticitems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitemsapi%2Felasticitems/lists"}