Задать вопрос

Тел: +7 965 3737 888

522

Просмотров

0

Ответов

PostgreSQL fulltext with language translations

<p>Consider following models:
</p>
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()
<p>With this snippet is possible search through all translations of product at the same time (using string concatenation in trigger):
</p>
Product.objects.extra(
    where = ['product_product.fulltext @@ to_tsquery(%s)'],
    params = [ 'someproduct' ]
)
<p>For PostgreSQL &gt;=8.4 only.
</p>

Вопрос полезен? Да0/Нет0
file_2504.sql(1.5Кб)
None