mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #3254 -- Added full text search to contrib.postgres.
Adds a reasonably feature complete implementation of full text search using the built in PostgreSQL engine. It uses public APIs from Expression and Lookup. With thanks to Tim Graham, Simon Charettes, Josh Smeaton, Mikey Ariel and many others for their advice and review. Particular thanks also go to the supporters of the contrib.postgres kickstarter.
This commit is contained in:
@@ -3,6 +3,7 @@ from django.db import connection, models
|
||||
from .fields import (
|
||||
ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField,
|
||||
FloatRangeField, HStoreField, IntegerRangeField, JSONField,
|
||||
SearchVectorField,
|
||||
)
|
||||
|
||||
|
||||
@@ -78,6 +79,37 @@ class CharFieldModel(models.Model):
|
||||
class TextFieldModel(models.Model):
|
||||
field = models.TextField()
|
||||
|
||||
def __str__(self):
|
||||
return self.field
|
||||
|
||||
|
||||
# Scene/Character/Line models are used to test full text search. They're
|
||||
# populated with content from Monty Python and the Holy Grail.
|
||||
class Scene(models.Model):
|
||||
scene = models.CharField(max_length=255)
|
||||
setting = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return self.scene
|
||||
|
||||
|
||||
class Character(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Line(PostgreSQLModel):
|
||||
scene = models.ForeignKey('Scene', models.CASCADE)
|
||||
character = models.ForeignKey('Character', models.CASCADE)
|
||||
dialogue = models.TextField(blank=True, null=True)
|
||||
dialogue_search_vector = SearchVectorField(blank=True, null=True)
|
||||
dialogue_config = models.CharField(max_length=100, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.dialogue or ''
|
||||
|
||||
|
||||
class RangesModel(PostgreSQLModel):
|
||||
ints = IntegerRangeField(blank=True, null=True)
|
||||
|
||||
Reference in New Issue
Block a user