{"id":20238509,"url":"https://github.com/marcinn/springy","last_synced_at":"2025-04-10T19:35:31.142Z","repository":{"id":57470324,"uuid":"45490978","full_name":"marcinn/springy","owner":"marcinn","description":"ElasticSearch DSL wrapper for Django","archived":false,"fork":false,"pushed_at":"2019-03-19T10:22:31.000Z","size":61,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T10:10:02.524Z","etag":null,"topics":["declarative","django","elasticsearch","python","python2","python3","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcinn.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":"2015-11-03T19:40:01.000Z","updated_at":"2017-11-24T17:13:06.000Z","dependencies_parsed_at":"2022-09-19T10:21:44.766Z","dependency_job_id":null,"html_url":"https://github.com/marcinn/springy","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fspringy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fspringy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fspringy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcinn%2Fspringy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcinn","download_url":"https://codeload.github.com/marcinn/springy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281423,"owners_count":21077423,"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":["declarative","django","elasticsearch","python","python2","python3","wrapper"],"created_at":"2024-11-14T08:34:33.082Z","updated_at":"2025-04-10T19:35:31.097Z","avatar_url":"https://github.com/marcinn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Springy\n\n![TravisBadge](https://travis-ci.org/marcinn/springy.svg?branch=master)\n\n\nSpringy is a Django wrapper for elasticsearch.\n\nOriginally based on BungieSearch, but with many conceptual changes.\nIt is written almost from scratch.\n\n\n## Design and goals\n\nSpringy is build over `elasticsearch-dsl-py` and `elasticsearch-py`.\n\nSpringy goals:\n\n* easy, queryset-like index querying\n* crossindex querying,\n* easy and fast indices managing,\n* easy document creation and validation,\n* mapping models to documents,\n* Django management commands,\n* multiple elastic databases/connections support,\n* connections routing,\n* automated document updates on model updates.\n\n\n## Current status\n\n* querying is available via extended `Search` class provided by\n  `elasticsearch-dsl`, which is wrapped in `Index` class\n* index managing supports `initialize` and `clear` operations\n* support for bulk create/update\n* updating index from QuerySet or any generator/iterable\n* simple composition layer for mapping models to documents\n  (`Index`)\n\n**Springy is under development. Use at own risk.**\n\n## Connections configuration\n\nSpringy requires connections configuration to be set in your project'\n`settings` module as an `ELASTIC_DATABASES` dictionary. Configuration\nis similar to Django `DATABASES` dictionary. \n\nThe default connection name/alias is called `default`. \n\nDatabases configuration is passed through to ElasticSearch-DSL\n`conncetions.configure()`, so for the details please look at\nhttp://elasticsearch-dsl.readthedocs.io/en/latest/configuration.html\n\nMinimalistic configuration:\n\n```python\nELASTIC_DATABASES = {\n    'default': {\n       'hosts': 'localhost',\n       }\n  }\n```\n## High-Level API\n\nHigh-Level API is located in `springy` namespace. To work with these shortcut methods you should call `springy.autodisover()` on application startup.\n\nAvailable methods:\n\n* `springy.autodiscover()` - find and register search indices in whole Django project\n* `springy.index(name)` - retrieve `Index` instance by its name\n* `springy.query(*indices)` - query specified indices by their names, returns `Search` lazy object\n* `springy.multisearch(index_name=None)` - construct MultiSearch object\n  with optional index to perform multisearch queries\n* `springy.parse(input_query_string)` - instantiate `Search` with DisMax query parser for specified input\n\n## Autodiscover and index registration\n\nIndices are automatically registered at the import time, so they must be imported explicite via `import` command or autodiscovered by Springy.\n\nThe minimal requirements for Django application are:\n  * put your app (`my_app` for example) into `INSTALLED_APPS`\n  * define indices in `my_app.search` module\n  * call `springy.autodiscover()` somewhere, for example in your project `urls` module.\n  \n*You can autodiscover any module in your apps. Just provide module name as an argument for `springy.autodiscover()`. The default is set to `search`.*\n\n## Examples\n\n### Defining an index\n\nThis declaration maps Product model into `products` index.  A proper doctype\nis automatically generated from specified fields and model definition.\n\n```python\nimport springy\n\nclass ProductIndex(springy.Index):\n    class Meta:\n        index = 'products'\n        model = Product\n        fields = ('name', 'description', 'price', 'default_picture')\n\n    def get_query_set(self):\n        return super(ProductIndex, self).get_query_set().filter(is_published=True)\n```\n\n*Warning! This API may be changed. ElasticSearch supports many DocTypes\nin one index, but index structure is shared between all. Index declaration will\nbe separated from doctype/models mappings.*\n\n### Index initialization\n\n```python\nidx = ProductIndex()\nidx.initialize() \n```\n\n### Indexing\n\n```python\nidx = ProductIndex()\nidx.update_index()\n```\n\nIndexing one model instance:\n\n```python\nidx = ProductIndex()\nobj = Product.objects.get(id=1)\nidx.save(obj)\n```\n\nIndexing a queryset:\n\n```python\nidx = ProductIndex()\nidx.save_many(Product.objects.filter(category__name='keyboards'))\n```\n\n\n### Querying\n\n```python\nidx = ProductIndex()\nresult = idx.query_string('mouse OR keyboard')\n```\n\nResult is a `IterableSearch` instance, a \"lazy\" object, which inherits directly\nfrom `Search` (see `elasticsearch-dsl` for more information and API).\n\n`Index` provides some useful query shortcuts:\n\n* `all()` - return all documents\n* `filter()` - shortcut to `Search.filter()`\n* `query()` - shortcut to `Search.query()`\n* `query_string()` - wrapper for querying by \"query string\" using DisMax parser.\n\n### Clearing and dropping index\n\nTo remove all documents from index:\n\n```python\nidx = ProductIndex()\nidx.clear_index()\n```\n\nTo drop index just call:\n\n```\nidx.drop_index()\n```\n\n## License\n\nBSD\n\n## Changelog\n\n`5.0.1`\n- introduced `Index.prepare_object()` method for easy overriding\n- index updating via `initialize` management command\n\n`5.0.0`\n- Initial support for ElasticSearch 5.x\n\n`0.3.11`\n- Added support for Python 3 (Django 1.7.x only for Python 3.4)\n- Supported Django versions are 1.7, 1.8, 1.9, 1.10, 1.11\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinn%2Fspringy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcinn%2Fspringy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinn%2Fspringy/lists"}