def register_indexex(self): register_index(Indexed, { 'name': ('iexact', 'endswith', 'istartswith', 'iendswith', 'contains', 'icontains', re.compile('^i+', re.I), re.compile('^I+'), re.compile('^i\d*i$', re.I)), 'published': ('month', 'day', 'year', 'week_day'), 'tags': ('iexact', 'icontains', StandardLookup() ), # 'foreignkey': 'iexact', 'foreignkey__title': 'iexact', 'foreignkey__name_fi': 'iexact', 'foreignkey__fk__name_fi2': ('iexact', 'endswith'), 'foreignkey2__name_fi2': (StandardLookup(), 'iexact'), 'foreignkey2__age': (StandardLookup()) }) register_index(ForeignIndexed, { 'title': 'iexact', 'name_fi': ('iexact', 'icontains'), 'fk__name_fi2': ('iexact', 'endswith'), 'fk__age': (StandardLookup()), })
from models import Recipe, Question from dbindexer.api import register_index register_index(Recipe, {'text': 'icontains'})
from dbindexer import autodiscover autodiscover() from facebook_app.models import Course from dbindexer.api import register_index register_index(Course, {'name': ('icontains', 'contains')}) #register_index(Course,{'teacher':('icontains','contains')})
from django.conf import settings if 'django.contrib.auth' in settings.INSTALLED_APPS: from dbindexer.api import register_index from django.contrib.auth.models import User register_index(User, { 'username': '******', 'email': 'iexact', }) if 'django.contrib.admin' in settings.INSTALLED_APPS: from dbindexer.api import register_index from django.contrib.admin.models import LogEntry register_index(LogEntry, { 'object_id': 'exact', })
from .models import Choice from dbindexer.api import register_index register_index(Choice, { 'poll__pub_date': 'year', })
from dbindexer.api import register_index from emailconfirmation.models import EmailAddress register_index(EmailAddress, {'email': 'iexact', })
from models import Book, Writer from dbindexer.api import register_index register_index(Book, {'search': 'icontains'}) register_index(Writer, {'search': 'icontains'})
from .models import Blog, Post from dbindexer.api import register_index from dbindexer import autodiscover autodiscover() register_index(Blog, {'title': 'icontains'}) #register_index(Post, {'title': 'icontains', 'url': 'icontains', 'author':'iexact'})
from prospects.models import Prospect from dbindexer.api import register_index register_index(Prospect, {'email': 'iexact'})
from dbindexer.lookups import StandardLookup from dbindexer.api import register_index from app_users.models import UserProfile register_index(UserProfile, {'user__username': (StandardLookup(), 'iexact'),})
from dbindexer.api import register_index from tagging.models import Tag register_index(MyModel, {'name': 'icontains'})
''' Created on Jan 5, 2014 @author: zhouguangyi2009 this module is to make sure ajango-autoload function well: ensure the registration of all database indexes specified in my project This file need to be stored in the same folder as settings.py ''' from dbindexer import autodiscover autodiscover() from myBlog.models import Author, Post from django.contrib.auth.models import User from dbindexer.lookups import StandardLookup from dbindexer.api import register_index register_index(Post,{'author__username': StandardLookup(),})
from models import Recipe, Question from dbindexer.api import register_index register_index(Recipe, {'name': 'icontains'}) register_index(Question, {'name': 'icontains'})
from models import Recipe, Question from dbindexer.api import register_index register_index(Recipe, {"text": "icontains"})
from models import Post from dbindexer.api import register_index register_index(Post, {'title': 'contains',})
from models import UploadModel from dbindexer.lookups import StandardLookup from dbindexer.api import register_index register_index(UploadModel, {'date': 'year'}) register_index(UploadModel, {'date': 'month'})
from django.contrib.auth.models import User from dbindexer.api import register_index register_index(User, { 'username': '******', 'email':'icontains', 'first_name':'icontains', 'last_name':'icontains' })
from models import VesselDetail, Passage from dbindexer.api import register_index register_index(VesselDetail, {'ship_name': 'istartswith'}) register_index(Passage, {'ship_name': 'icontains'}) #register_index(Passage, {'date_added': 'day'}) #register_index(Passage, {'date_added': 'month'}) #register_index(Passage, {'date_added': 'year'})
from dbindexer import autodiscover autodiscover() from facebook_app.models import Course from dbindexer.api import register_index register_index(Course,{'name':('icontains','contains')}) #register_index(Course,{'teacher':('icontains','contains')})
title = models.CharField(max_length=500) name_fi = models.CharField(max_length=500) fk = models.ForeignKey(ForeignIndexed2, null=True) class Indexed(models.Model): name = models.CharField(max_length=500) published = models.DateTimeField(auto_now_add=True) foreignkey = models.ForeignKey(ForeignIndexed, null=True) foreignkey2 = models.ForeignKey(ForeignIndexed2, related_name='idx_set', null=True) register_index(Indexed, { 'name': ('iexact', 'endswith', 'istartswith', 'iendswith', 'contains', 'icontains', re.compile('^i+', re.I), re.compile('^I+'), re.compile('^i\d*i$', re.I)), 'published': ('month', 'day', 'week_day'), 'foreignkey': 'iexact', 'foreignkey__title': 'iexact', 'foreignkey__fk__name_fi2': 'iexact', 'foreignkey__name_fi': 'iexact', 'foreignkey2__name_fi2': '$default' }) class TestIndexed(TestCase): def setUp(self): juubi = ForeignIndexed2(name_fi2='Juubi') juubi.save() kyuubi = ForeignIndexed(name_fi='Kyuubi', title='Bijuu', fk=juubi) kyuubi.save() Indexed(name='ItAchi', foreignkey=kyuubi, foreignkey2=juubi).save() Indexed(name='YondAimE', foreignkey=kyuubi, foreignkey2=juubi).save() Indexed(name='I1038593i', foreignkey=kyuubi, foreignkey2=juubi).save()
from models import Question, Questionnaire from dbindexer.lookups import StandardLookup from dbindexer.api import register_index register_index(Question, {'questionnaire__product__uniqueName': StandardLookup()}) register_index(Questionnaire, {'product__uniqueName': StandardLookup()})
from dbindexer.api import register_index from pirate_forum.models import View # dbindexes.py: register_index(View, {'modified_dt': 'month', 'modified_dt': 'day', 'modified_dt': 'year', 'created_dt': 'month', 'created_dt': 'day', 'created_dt': 'year'})
from models import * from dbindexer.lookups import StandardLookup from dbindexer.api import register_index register_index(Boban, {'email': 'iexact', 'last_name': 'icontains', })
# for use when you are using django non-rel which needs # a little help to be able to execute some 'complex' queries. from django.contrib.auth.models import User from dbindexer.api import register_index register_index(User, { 'username': '******', 'email': 'iexact', })
from models import Post from dbindexer.api import register_index register_index(Post, {'title': ('iexact', 'icontains')})
from models import Order from dbindexer.api import register_index import logging logging.info("registering index") register_index(Order, {'from_raw': 'icontains', 'to_raw': 'icontains'})
from books.models import Book from dbindexer.api import register_index register_index(Book, {"title": {"contains"}})
# models.py: class MyModel(models.Model): name = models.CharField(max_length=64) last_modified = models.DateTimeField(auto_now=True) def run_query(name, month): MyModel.objects.filter(name__iexact=name, last_modified__month=month) # dbindexes.py: from models import MyModel from dbindexer.api import register_index register_index(MyModel, {'name': 'iexact', 'last_modified': 'month'})
from models import Survey from dbindexer.lookups import StandardLookup from dbindexer.api import register_index register_index(Survey, {'user__username': StandardLookup()})
published = models.DateTimeField(auto_now_add=True) foreignkey = models.ForeignKey(ForeignIndexed, null=True) foreignkey2 = models.ForeignKey(ForeignIndexed2, related_name='idx_set', null=True) register_index( Indexed, { 'name': ('iexact', 'endswith', 'istartswith', 'iendswith', 'contains', 'icontains', re.compile( '^i+', re.I), re.compile('^I+'), re.compile('^i\d*i$', re.I)), 'published': ('month', 'day', 'week_day'), 'foreignkey': 'iexact', 'foreignkey__title': 'iexact', 'foreignkey__fk__name_fi2': 'iexact', 'foreignkey__name_fi': 'iexact', 'foreignkey2__name_fi2': '$default' }) class TestIndexed(TestCase): def setUp(self): juubi = ForeignIndexed2(name_fi2='Juubi') juubi.save() kyuubi = ForeignIndexed(name_fi='Kyuubi', title='Bijuu', fk=juubi)
from models import Profile, Skill from dbindexer.api import register_index register_index(Profile, {'full_name': 'icontains', 'email': 'icontains'}) register_index(Skill, {'name': 'icontains'})
from models import items from dbindexer.api import register_index register_index(items, {'title': ('icontains'), 'title_join_descrip': ('icontains')})
from temprly.models import * from dbindexer.lookups import StandardLookup from dbindexer.api import register_index register_index(SensorReading, {'sensor__name': StandardLookup(), 'sensor__location': StandardLookup(), 'sensor__location__name': StandardLookup(), 'sensor__location__id': StandardLookup(), 'sensor__location__owner__username': StandardLookup(), })