{ "info": { "author": "Blake VandeMerwe", "author_email": "blakev@null.net", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only" ], "description": "# Flask-WhooshAlchemy3\n[![PyPI version](https://badge.fury.io/py/flask-whooshalchemy3.svg)](https://badge.fury.io/py/flask-whooshalchemy3)\n[![license](https://img.shields.io/github/license/blakev/flask-whooshalchemy3.svg)]()\n\nWhoosh indexing capabilities for Flask-SQLAlchemy, Python 3 compatibility fork.\nPerformance improvements and suggestions are readily welcome.\n\nInspired from gyllstromk's [Flask-WhooshAlchemy](https://github.com/gyllstromk/Flask-WhooshAlchemy).\n\n- [Whoosh](http://whoosh.readthedocs.io/en/latest/intro.html)\n- [Flask-SqlAlchemy](http://flask-sqlalchemy.pocoo.org/2.1/)\n\n\n## Install\n\n```bash\n$ pip install flask-whooshalchemy3\n```\n\n..alternatively from source,\n\n```bash\n$ pip install git+git://github.com/blakev/Flask-WhooshAlchemy3.git@master\n```\n\n\n## Quickstart\n\n```python\n\nfrom datetime import datetime\n\nimport flask_sqlalchemy\nimport flask_whooshalchemy\nfrom whoosh.analysis import StemmingAnalyzer\n\ndb = flask_sqlalchemy.SQLAlchemy()\n\nclass BlogPost(db.Model):\n __tablename__ = 'posts'\n __searchable__ = ['title', 'content', 'summary'] # indexed fields\n __analyzer__ = StemmingAnalyzer()\n \n id = db.Column(db.Integer, primary_key=True)\n title = db.Column(db.String(255), unique=True)\n content = db.Column(db.Text(32*1024))\n summary = db.Column(db.String(1024))\n created = db.Column(db.DateTime, default=datetime.utcnow)\n\n```\n\nCommitting model instances to the session will write or update the Whoosh index.\n\n```python\ndb.session.add(BlogPost(title='First Post!', content='This is awesome.'))\ndb.session.commit()\n```\n\nSearching is done via `Model.query.search(..)`. However, the request must be done within the Flask\nrequest context otherwise the database connection may not be established.\n\n```python\n@app.route('/posts')\ndef posts():\n num_posts = min(request.args.get('limit', 10), 50)\n query = request.args.get('q', '')\n results = BlogPost.query.search(query, limit=num_posts)\n```\n\n\nResults are ordered by Whoosh's ranking-algorithm, but can be overwritten with SQLAlchemy `.order_by`.\n\n```python\nyesterday = datetime.utcnow() - timedelta(days=1)\nresults = BlogPost.query\n .filter(BlogPost.created > yesterday)\n .search('first')\n .order_by(desc(BlogPost.created))\n```\n\n## Flask Configuration\n\n`WHOOSH_ANALYZER` **(whoosh.Analyzer)**\n- Sets the global text analyzer, available options [in Whoosh documentation](http://whoosh.readthedocs.io/en/latest/analysis.html). \n- Default: `StemmingAnalyzer`.\n\n`WHOOSH_INDEX_PATH` (str)\n- File path to where the text indexes will be saved. \n- Default: `{cwd}/.indexes/*`\n\n`WHOOSH_INDEXING_CPUS` (int)\n- The number of system processes to spawn for indexing new and modified documents.\n- Default: `2`\n\n`WHOOSH_INDEXING_RAM` (int)\n- The amount of RAM, in megabytes, to reserve per indexing process for data processing.\n- Default: `256`\n\n`WHOOSH_RAM_CACHE` (bool)\n- Allows common queries and their fields to be stored in cache, in RAM.\n- Default: `False`\n\n## License\n\n```text\nMIT License\n\nCopyright (c) 2017 Blake VandeMerwe\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```", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/blakev/Flask-WhooshAlchemy3", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "flask-whooshalchemy3", "package_url": "https://pypi.org/project/flask-whooshalchemy3/", "platform": "", "project_url": "https://pypi.org/project/flask-whooshalchemy3/", "project_urls": { "Homepage": "https://github.com/blakev/Flask-WhooshAlchemy3" }, "release_url": "https://pypi.org/project/flask-whooshalchemy3/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Whoosh indexing capabilities for Flask-SQLAlchemy, Python 3 compatible.", "version": "0.1.2" }, "last_serial": 5210340, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "445c47ad930945deefbce75855800c5c", "sha256": "a894f90bb93cffdde8308591e01090b348f864e29e39505097501f7d5d303592" }, "downloads": -1, "filename": "flask-whooshalchemy3-0.1.0.tar.gz", "has_sig": false, "md5_digest": "445c47ad930945deefbce75855800c5c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8357, "upload_time": "2017-08-18T23:07:04", "url": "https://files.pythonhosted.org/packages/95/03/e82e01c23915a94d3110e1e9f66c38e632f3013ea73380214ca5626e47dd/flask-whooshalchemy3-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b2c81f05cab9f492dde0c8bd26ca2bd7", "sha256": "85fe44af6431ab8e1c8b261b384669cbda55eeace8d59e419e578ba512f2fdef" }, "downloads": -1, "filename": "flask-whooshalchemy3-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b2c81f05cab9f492dde0c8bd26ca2bd7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8431, "upload_time": "2017-08-18T23:13:14", "url": "https://files.pythonhosted.org/packages/19/16/6f885678e8806a6a2fc76d14e5e956feaf924558856ce28edc89e07b0e55/flask-whooshalchemy3-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "c7f65cfc7ba890c10a99528f20849143", "sha256": "4d65d579ba9fe97a31985c07c75aa4b066a79a27f4654fc51fbca7d15189c8c1" }, "downloads": -1, "filename": "flask-whooshalchemy3-0.1.2.tar.gz", "has_sig": false, "md5_digest": "c7f65cfc7ba890c10a99528f20849143", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8956, "upload_time": "2019-04-30T22:21:01", "url": "https://files.pythonhosted.org/packages/ae/1b/b4a62995250d7fbdb4d95e1471848a071df3a0a8150675647c8cbcf3f87a/flask-whooshalchemy3-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c7f65cfc7ba890c10a99528f20849143", "sha256": "4d65d579ba9fe97a31985c07c75aa4b066a79a27f4654fc51fbca7d15189c8c1" }, "downloads": -1, "filename": "flask-whooshalchemy3-0.1.2.tar.gz", "has_sig": false, "md5_digest": "c7f65cfc7ba890c10a99528f20849143", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8956, "upload_time": "2019-04-30T22:21:01", "url": "https://files.pythonhosted.org/packages/ae/1b/b4a62995250d7fbdb4d95e1471848a071df3a0a8150675647c8cbcf3f87a/flask-whooshalchemy3-0.1.2.tar.gz" } ] }