{"id":13771514,"url":"https://github.com/SurveyMonkey/wukong","last_synced_at":"2025-05-11T04:30:44.688Z","repository":{"id":55619013,"uuid":"66986285","full_name":"SurveyMonkey/wukong","owner":"SurveyMonkey","description":"An ORM Client library for SolrCloud http://wukong.readthedocs.io/en/latest/","archived":false,"fork":false,"pushed_at":"2020-09-15T21:50:54.000Z","size":86,"stargazers_count":13,"open_issues_count":2,"forks_count":6,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-14T16:48:25.217Z","etag":null,"topics":["orm","solr","solrcloud"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"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/SurveyMonkey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2016-08-30T23:56:22.000Z","updated_at":"2023-01-05T21:33:03.000Z","dependencies_parsed_at":"2022-08-15T04:40:19.010Z","dependency_job_id":null,"html_url":"https://github.com/SurveyMonkey/wukong","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurveyMonkey%2Fwukong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurveyMonkey%2Fwukong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurveyMonkey%2Fwukong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SurveyMonkey%2Fwukong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SurveyMonkey","download_url":"https://codeload.github.com/SurveyMonkey/wukong/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253518941,"owners_count":21921074,"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":["orm","solr","solrcloud"],"created_at":"2024-08-03T17:00:52.290Z","updated_at":"2025-05-11T04:30:44.310Z","avatar_url":"https://github.com/SurveyMonkey.png","language":"Python","funding_links":[],"categories":["ODM, ORM, Active Record"],"sub_categories":[],"readme":"# Wukong\n\n[![Latest Version](https://badge.fury.io/py/wukong.svg)](https://pypi.python.org/pypi/wukong/)\n[![Travis CI Build Status](https://travis-ci.org/SurveyMonkey/wukong.svg?branch=master)](https://travis-ci.org/SurveyMonkey/wukong)\n[![Coveralls Coverage Status](https://coveralls.io/repos/github/SurveyMonkey/wukong/badge.svg?branch=master)](https://coveralls.io/github/SurveyMonkey/wukong?branch=master)\n\n\nWukong offers an ORM query engine for Solr and Solr Cloud.\n\n## Installation\n```\n\tpip install wukong\n```\n\n## Usage\n\n\n### Create Solr Collection\nBefore you use wukong, make sure you already created your collection on SolrCloud. For example,\n```\n\tcurl http://localhost:8080/solr/admin/collections?action=CREATE\u0026name=users\u0026numShards=1\u0026replicationFactor=2\n```\n\nA sample schema can be like:\n```\n\u003cfields\u003e\n\t\u003cuniqueKey\u003eid\u003c/uniqueKey\u003e\n  \t\u003cfield name=\"id\" type=\"int\" indexed=\"true\" stored=\"true\" required=\"true\" /\u003e\n\t\u003cfield name=\"name\" type=\"string\" indexed=\"true\" stored=\"true\" required=\"true\"/\u003e\n\t\u003cfield name=\"city\" type=\"string\" indexed=\"true\" stored=\"true\"/\u003e\n\t\u003cfield name=\"age\" type=\"int\" indexed=\"true\" stored=\"true\"/\u003e\n\t...\n\u003c/fields\u003e\n```\n\n### Create a model class for Solr collection\nCreate a class for your Solr collection by extending the class `SolrDoc`. For example,\n\n```\nfrom wukong.models import SolrDoc\n\nclass User(SolrDoc):\n    collection_name = \"users\"\n    solr_hosts = \"localhost:8080,localhost:8081\"\n\n    def validate_schema_fields(self, fields):\n    \tpass\n\n    def get_data_for_solr(self):\n    \tpass\n\n```\nYou can overide existing methods to fit your business logic, like `validate_schema_fields`, `get_data_for_solr`.\n\n\n### Use Solr QueryManger\n\nCreat a document\n```\nUser.documents.create(User_id=12345, name=\"Test Name\", city=\"Test City\")\n```\n\nUpdate a document\n```\nUser.documents.update(User_id=12345, name=\"Test Name\")\n```\n\nTo index a batch of documentsto your Solr collection, use the container class: SolrDocs. Instead of accessing SOLR\nmultiple times, it only issues one request to SOLR, which is more efficient.\n\n```\n\tdocs = [\n\t\tUser(User_id=12345, name=\"Test Name1\", city=\"Test Cit1\"),\n\t\tUser(User_id=123456, name=\"Test Name2\", city=\"Test City2\")\n\t\t...\n\t]\n\tdocs = SolrDocs(docs)\n\tdocs.index()\n```\n\nFetch a document\n```\nUser.documents.get(User_id__eq=12345)\n```\n\nFetch multiple documents\n```\nUser.documents.filter(name__eq=\"Test Name\", city__wc=\"Test*\").all()\n```\n\nUse compounded logic\n```\nUser.documents.filter(OR(city__wc=\"Test*\", name__eq=\"Test Name\"))\n```\n\nSort by a field\n```\nUser.documents.sort_by(\"-name\").all()\n```\n\nForce only return a certain fields\n```\nUser.documents.only(\"is\", \"name\").all()\n```\n\nForce only return the top 10 documents\n```\nUser.documents.limit(10).all()\n```\n\nChain the query methods\n```\nUser.documents.filter(city__wc=\"Test*\").sort_by(\"-name\").limit(10).all()\n```\n\nDelete a document\n```\nUser.documents.get(User_id__eq=12345).delete()\n```\n\nBatch delete documents\n```\nUser.documents.filter(name__eq=\"Test Name\").all().delete()\n```\n\n## Documentations\n\nDetailed docs can be found at http://wukong.readthedocs.io/en/latest/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSurveyMonkey%2Fwukong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSurveyMonkey%2Fwukong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSurveyMonkey%2Fwukong/lists"}