Git Product home page Git Product logo

ponywhoosh's Introduction

ponywhoosh

PyPI Package latest release Test

Make your database over PonyORM searchable.

Install package, import and start adding what fields of your models in your database, you want to search.

PonyWhoosh

Please take a look to the official documentation up to date:

Installation

pip install ponywhoosh

or use the develop (unstable) version:

git clone https://github.com/jonaprieto/ponywhoosh.git
cd ponywhoosh
python setup.py install

ponywhoosh's People

Contributors

jonaprieto avatar piperod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

oscarpicas benzei

ponywhoosh's Issues

Python 3 support

Hi!
Are there any plans on supporting Python 3 in the future?

Py3 Error

There is a problem in the middle_save. tha causes this

% python example.py runserver
Traceback (most recent call last):
  File "example.py", line 212, in <module>
    populate_database()
  File "<string>", line 2, in populate_database
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/pony/orm/core.py", line 413, in new_func
    try: return func(*args, **kwargs)
  File "example.py", line 208, in populate_database
    commit()
  File "<string>", line 2, in commit
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/pony/utils/utils.py", line 58, in cut_traceback
    return func(*args, **kwargs)
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/pony/orm/core.py", line 293, in commit
    cache.flush()
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/pony/orm/core.py", line 1620, in flush
    cache.call_after_save_hooks()
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/pony/orm/core.py", line 1628, in call_after_save_hooks
    obj._after_save_(status)
  File "/Users/mac/Proyectos/Jona/ponywhoosh/ponywhoosh/core.py", line 203, in _middle_save_
    writer.add_document(**attrs)
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/whoosh/writing.py", line 750, in add_document
    for tbytes, freq, weight, vbytes in items:
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/whoosh/fields.py", line 669, in index
    yield (self.to_bytes(num, shift), 1, 1.0, emptybytes)
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/whoosh/fields.py", line 722, in to_bytes
    x = self.prepare_number(x)
  File "/Users/mac/miniconda3/envs/FPW/lib/python3.6/site-packages/whoosh/fields.py", line 685, in prepare_number
    x = self.numtype(x)
ValueError: invalid literal for int() with base 10: '3.000000000'

No results, index not created, and problem with primary key

I use ponywhoosh as specified:

@pw.register_model('name', sortable=True, stored=True)
class Product(pony_db.Entity):
   name = pony.orm.Required(str, 200, unique=True)
@app.route('/search', methods=['GET'])
@limiter.limit("1000/day")
@pony.orm.db_session
def search():
    query = request.args.get('query', type=str)
    print('query', query)
    return json.dumps(models.pw.search(query))

Searching show no results with a populated database and exact query.
By looking into the index folder, I realized that indexes were not built. So I tried the following:

Product._pw_index_.update_documents()

I get this error:

  File "/usr/local/lib/python3.6/dist-packages/ponywhoosh/index.py", line 136, in charge_documents
    attrs = {self._primary_key: obj.get_pk()}

TypeError: unhashable type: 'list'

Do you have any clue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.