Giter Club home page Giter Club logo

django-fts-odeon's Introduction

django-fts-odeon is a fork of django-fts ( http://code.google.com/p/django-fts/ )
The only supported back-end is PostgreSQL

Dependencies:
- Django
- PostgreSQL

Install:
- add "FTS_BACKEND = 'pgsql://' " in settings.py and "fts" to INSTALLED_APPS
- ./manage.py migrate fts

Usage:
- subclass your model from fts.SearchableModel
- create a custom manager with the list of fields that should be indexed (CharField and TextField only)

class Blog(fts.SearchableModel):
    title = models.CharField(max_length=100)
    body = models.TextField()
    search_objects = fts.SearchManager(fields=('title', 'body')) # index both fields
    
- create FTS indices with ./manage.py create_fts_indices
- if you need to update by hand all the search indices for some reason, you can do "./manage.py update_fts_indices". Normally, the indices are always up to date because postgres takes care of them on each insert/update/delete.

- getting the results ordered by rank in postgres (the rank field's name is not important. Just avoid any clashes with existing fields):
  Blog.search_objects.search('foo bar', rank_field='rank')

- highlighting results (highlight_field is the actual model field where you want the highlighting done. The modified text will be placed in a new field called highlight_field+'_highlight'):

for blog in Blog.search_objects.search('foo bar', highlight_field='body'):
    print blog.body_highlight

- see fts_test/tests.py for more examples

website: http://od-eon.com/labs/django-fts-odeon/
contact: [email protected]

django-fts-odeon's People

Contributors

stefantalpalaru avatar odeoncg avatar

Stargazers

 avatar Calvin Cheng avatar

Watchers

Calvin Cheng avatar Liviu Chiributa avatar  avatar James Cloos avatar Nai avatar

Forkers

odeoncg inmeet

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.