fields = [('asciified_all_names_string', 1000), ('asciified_public_real_name', 500), 'asciified_location', 'plaintext_notes'] space.add_index(Releaser, ReleaserIndexer, attach_as='indexer') class ReleaserIndexerWithRealNames(Indexer): fields = [('asciified_all_names_string', 1000), ('asciified_real_name', 500), 'asciified_location', 'plaintext_notes'] space.add_index(Releaser, ReleaserIndexerWithRealNames, attach_as='indexer_with_real_names') # TODO: index PartySeries (also platform?) class PartyIndexer(Indexer): fields = [('asciified_name', 1000), 'asciified_location', ('tagline', 200), 'plaintext_notes'] space.add_index(Party, PartyIndexer, attach_as='indexer') complete_indexer = CompositeIndexer(Production.indexer, Releaser.indexer, Party.indexer) complete_indexer_with_real_names = CompositeIndexer(Production.indexer, Releaser.indexer_with_real_names, Party.indexer) class ProductionNameIndexer(Indexer): fields = ['asciified_title'] space.add_index(Production, ProductionNameIndexer, attach_as='name_indexer') class ReleaserNameIndexer(Indexer): fields = ['asciified_all_names_string', 'asciified_public_real_name'] space.add_index(Releaser, ReleaserNameIndexer, attach_as='name_indexer') class ReleaserNameIndexerWithRealNames(Indexer): fields = ['asciified_all_names_string', 'asciified_real_name']
def test_collapse_composite(self): # all entries have the same author indexer = CompositeIndexer(Entry.indexer, Comment.indexer) self.assertEqual( indexer.search("test").collapse_by("author").count(), 1)
""" Copyright (C) 2013 Michael Davidsaver Licensed under AGPL 3+ See file "LICENSE" for full terms """ from djapian import space, Indexer, CompositeIndexer from models import Part class PartIndexer(Indexer): fields = ['desc', 'partnum'] space.add_index(Part, PartIndexer, attach_as='indexer') complete_indexer = CompositeIndexer(Part.indexer)
def test_collapse_composite(self): # all entries have the same author indexer = CompositeIndexer(Entry.indexer, Comment.indexer) self.assertEqual(indexer.search("test").collapse_by("author").count(), 1)
from djapian import space, Indexer, CompositeIndexer from OneTree.apps.common.models import * from OneTree.apps.common.group import * from OneTree.apps.common.user import * class GroupIndexer(Indexer): fields = ['name', 'keywords'] tags = [ ('name', 'name'), ] space.add_index(Group, GroupIndexer, attach_as='indexer') complete_indexer = CompositeIndexer(Group.indexer)
fields = ['title','description','total_budget','organisation'] tags = [ ('identifier','identifier'), ('organisation','organisation'), ('title','title'), ('description','description'), ('sector','sector'), ('sector_code','sector_code'), ('pk','pk'), ('total_budget','total_budget'), ('cntr','recipient_country_code',3), #('last_updated','last_updated'), ] space.add_index(Activity,ActivityIndexer,attach_as='indexer') #class TransactionIndexer(Indexer): #fields = ['activity.title'] #tags = [ #('transaction_type','transaction_type'), #('provider_org','provider_org'), #('reciver_org','reciver_org'), #('value','value'), #('value_date','value_date'), #('transaction_date','transaction_date'), #] #space.add_index(Transaction,TransactionIndexer,attach_as='indexer') #complete_indexer = CompositeIndexer(RecipientCountryBudget.indexer,Activity.indexer,Transaction.indexer) complete_indexer = CompositeIndexer(Activity.indexer)
from pyv4.demands.models import Demand class PostIndexer(Indexer): fields = ['contents'] tags = [('author', 'author'), ('date_created', 'date_created')] class NewsIndexer(Indexer): fields = ['title', 'intro', 'body'] tags = [('title', 'title'), ('author', 'author'), ('date_published', 'date_published')] class WikiIndexer(Indexer): fields = ['body'] tags = [('title', 'title'), ('lang', 'lang')] class DemandIndexer(Indexer): fields = ['title', 'content'] tags = [('title', 'title'), ('content', 'content')] space.add_index(Post, PostIndexer, attach_as='indexer') space.add_index(Page, WikiIndexer, attach_as='indexer') space.add_index(News, NewsIndexer, attach_as='indexer') space.add_index(Demand, DemandIndexer, attach_as='indexer') complete_indexer = CompositeIndexer(Post.indexer, Page.indexer, News.indexer, Demand.indexer)