Login

Tag "full-text"

Snippet List

PostgreSQL fulltext with language translations

Consider following models: class Product(models.Model): code = modeld.CharField() class ProductTrans(models.Model): product = models.ForeignKey('Product') language = models.ChoiceField(choices=settings.LANGUAGES) title = models.ChaField() description = models.ChaField() With this snippet is possible search through all translations of product at the same time (using string concatenation in trigger): Product.objects.extra( where = ['product_product.fulltext @@ to_tsquery(%s)'], params = [ 'someproduct' ] ) For PostgreSQL >=8.4 only.

  • sql
  • models
  • translations
  • model
  • full-text
  • postgres
  • postgresql
  • language
  • fulltext
  • translation
Read More

Full-Text Searchable Models

A drop-in module to allow for full-text searchable models with very little effort. Tested with PostgreSQL 8.3, but should work on earlier versions with the tsearch2 module installed.

  • models
  • search
  • full-text
  • tsearch2
Read More

Sphinx Search ORM / Revised

A revised version of [zeeg's Sphinx Search ORM](http://www.djangosnippets.org/snippets/231/), using my Sphinx client and adding support for Sphinx's excerpt generator. It's still missing support for search modes/order_by/filter/exclude, but it should be easy and I will add the relevant methods soon as I need them. Usage is the same as zeeg's class, except that you can pass a field name (or tuple for related objects) to its constructor, that will be used for excerpts: class MyModel(models.Model): search = SphinxSearch(excerpts_field='description') MyModel.search.query('query') MyModel.search.query('query').count() Returns an ordered list of the objects in your database.

  • search
  • sphinx
  • full-text
Read More

Sphinx Search ORM

An ORM model for the Sphinx full-text search engine. See http://www.sphinxsearch.com/ for more information. It currently supports the following: class MyModel(models.Model): search = SphinxSearch() MyModel.search.query('query') MyModel.search.query('query').order_by('@weight', '@id', 'my_attribute') MyModel.search.query('query').filter(my_attribute=5) MyModel.search.query('query').filter(my_other_attribute=[5, 3,4]) MyModel.search.query('query').exclude(my_attribute=5)[0:10] MyModel.search.query('query').count() SphinxSearch().query('hello').on_index('model_myapp model_myotherapp') Returns an ordered list of the objects in your database. -- Update: New Methods: * count() * index_on(<str index>) * extra(<see django>) * all() (does nothing) * select_related(<see django>) * group_by(<str attribute>, <const function>[, <str sort>) * weights(<list weights>)

  • search
  • sphinx
  • full-text
Read More

4 snippets posted so far.