示例#1
0
from djapian import space, Indexer
from sjphoto.base.models import Gallery

class GalleryIndexer(Indexer):
    fields = ['title', 'description']
    tags = [
        ('title', 'title', 3),
        ('description', 'description', 2)
    ]

space.add_index(Gallery, GalleryIndexer, attach_as="indexer")
示例#2
0
from djapian import space, Indexer, CompositeIndexer

from libros.models import *

try:
    space.add_index(Tematica, attach_as='indexer')
except:
    pass
    
class LibroIndexer(Indexer):
    fields = ['descritores','resumen','nota_descriptiva']
    tags = [
        ('titulo', 'titulo'),
        ('autor', 'autor'),
        ('codigo', 'edicion'),
        ('tematica', 'tematica'),
        ('editorial', 'editorial'),
        ('fecha_pub', 'fecha_pub')
    ]
try:
    space.add_index(Libro, LibroIndexer, attach_as='indexer')
except:
    pass
    
class OrganizacionIndexer(Indexer):
   tags = [
       ('nombre', 'nombre'),
   ]
try:
    space.add_index(Organizacion, OrganizacionIndexer, attach_as='indexer')
except:
'''
Created on Nov 23, 2010

@author: Eric
'''
from djapian import space, Indexer
from models import Article

class ArticleIndexer(Indexer):
    fields = ['title','content']
    tags = [
        ('title','title', 3),
        ('content', 'as_plain_text', 1)
    ]

space.add_index(Article, ArticleIndexer, attach_as='indexer')
示例#4
0
文件: index.py 项目: tubergen/OneTree
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)
示例#5
0
from djapian import space, Indexer, CompositeIndexer

from demoscene.models import Releaser
from parties.models import Party
from productions.models import Production


class ProductionIndexer(Indexer):
	fields = [('asciified_title', 1000), 'tags_string', 'indexed_notes']
space.add_index(Production, ProductionIndexer, attach_as='indexer')


class ReleaserIndexer(Indexer):
	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)
示例#6
0
from djapian import space, Indexer, CompositeIndexer
import xapian

from models import Recipient, Payment, Scheme, Port, illegalFishing, EffData

class RecipientIndexer(Indexer):
    fields = ['pk', 'name', 'geo1', 'geo2','payment.amount']

    tags = [
        ('country', 'country'),
        ('type', 'recipient_type'),
        ('name', 'name', 10),
    ]
space.add_index(Recipient, RecipientIndexer, attach_as='indexer')

class SchemeIndexer(Indexer):
    fields = ['name_en','name_es']
space.add_index(Scheme, SchemeIndexer, attach_as='indexer')

class PortIndexer(Indexer):
    fields = ['name','geo1', 'geo2', 'country']
space.add_index(Port, PortIndexer, attach_as='indexer')
示例#7
0
文件: index.py 项目: ahiscox/docdump
from frontend.scans.models import *

class ScanIndexer(Indexer):
    """
        xapian indexing of scan ocr, date, time and tags.
    """

    fields = ['ocr']
    tags = [
        ('datedir', 'datedir'),
        ('timedir', 'timedir'),
        ('filename', 'filename'),
        ('ocr', 'ocr')
    ]

space.add_index(Scan, ScanIndexer, attach_as='search')

class CommentIndexer(Indexer):
    """
        xapian comment indexing.
    """

    fields = ['name', 'content']
    tags = [
        ('name', 'name'),
        ('content', 'content')
    ]

space.add_index(Comment, CommentIndexer, attach_as='search')

class TagIndexer(Indexer):
示例#8
0
文件: index.py 项目: gvidon/byhands
from djapian      import space, Indexer, CompositeIndexer
from candy.models import Category, Product

class CategoryIndexer(Indexer):
	fields = [('title', 2), ('description', 2)]

class ProductIndexer(Indexer):
	fields = [('title', 10), ('description', 1)]
	
space.add_index(Category, CategoryIndexer, attach_as='indexer')
space.add_index(Product , ProductIndexer, attach_as='indexer')

complete_indexer = CompositeIndexer(Category.indexer, Product.indexer)
示例#9
0
class JaxerNameSpaceIndexer(Indexer):
    fields = ['name', 'content', 'search_name']
    tags = [
        ('name','name'),
        ('content','content'),
        ('search_name', 'search_name')
    ]
class JaxerFunctionIndexer(Indexer):
    fields = ['name', 'content']
    tags = [
        ('name','name'),
        ('content','content')
    ]
class JaxerParameterIndexer(Indexer):
    fields = ['name', 'content']
    tags = [
        ('name','name'),
        ('content','content')
    ]
class JaxerPropertyIndexer(Indexer):
    fields = ['name', 'content']
    tags = [
        ('name','name'),
        ('content','content')
    ]    
space.add_index(JavascriptObject, JSObjectIndexer, attach_as='indexer')
space.add_index(ClassItem, ClassItemIndexer, attach_as='indexer')
space.add_index(JaxerNameSpace, JaxerNameSpaceIndexer, attach_as='ns_indexer')
space.add_index(Function, JaxerFunctionIndexer, attach_as='indexer')
space.add_index(Parameter, JaxerParameterIndexer, attach_as='indexer')
space.add_index(Property, JaxerPropertyIndexer, attach_as='indexer')
示例#10
0
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)
示例#11
0
from djapian import space, Indexer
from movieApp.models import movie

class movieEntry(Indexer):
    fields = [('name', 2), ]

    def trigger(indexer, object):
        return object.is_published

space.add_index(movie, movieEntry, attach_as='indexer')
示例#12
0
文件: index.py 项目: phadej/kamu
from djapian import space, Indexer, CompositeIndexer

from kamu.votes.models import *

class MemberIndexer(Indexer):
    fields = ['name', 'given_names', 'surname', 'email', 'phone']
space.add_index(Member, MemberIndexer, attach_as='indexer')

class SessionIndexer(Indexer):
    fields = ['info', 'subject']
space.add_index(Session, SessionIndexer, attach_as='indexer')

class StatementIndexer(Indexer):
    fields = ['text']
space.add_index(Statement, StatementIndexer, attach_as='indexer')

complete_indexer = CompositeIndexer(Member.indexer, Session.indexer, Statement.indexer)
示例#13
0
class ActivityIndexer(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)
示例#14
0
from djapian import space, Indexer, CompositeIndexer

from movies.models import Movie
from persons.models import Actor

class MovieIndexer(Indexer):
    fields = ['summary', 'summary_he']
    tags = [
        ('title', 'title', 3),
        ('title_he', 'title_he', 3),
        ('publish_year', 'publish_year'),
        ('tags', 'tags'),
    ]
    
class ActorIndexer(Indexer):
    fields = ['bio', 'bio_he' ]
    tags = [
        ('name', 'name', 3),
        ('name_he', 'name_he', 3),
        ('tags', 'tags'),
    ]
    

space.add_index(Movie, MovieIndexer, attach_as='indexer')
space.add_index(Actor, ActorIndexer, attach_as='indexer')

complete_indexer = CompositeIndexer(Movie.indexer, Actor.indexer)
示例#15
0
from djapian import space, Indexer, CompositeIndexer

from store.models import Store

class StoreIndexer(Indexer):
    fields=['name']

space.add_index(Store,StoreIndexer,attach_as='indexer')
store_indexers=CompositeIndexer(Store.indexer)
示例#16
0
from djapian import space, Indexer, CompositeIndexer

from demoscene.models import *
from parties.models import *


class ProductionIndexer(Indexer):
	fields = [('asciified_title', 1000), 'tags_string', 'plaintext_notes']
space.add_index(Production, ProductionIndexer, attach_as='indexer')


class ReleaserIndexer(Indexer):
	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)

示例#17
0
try:
    from djapian import space, Indexer
    from sphene.sphboard.models import Post

    class PostIndexer(Indexer):
        fields = [('subject', 20), 'body']
        tags = [
            ('subject', 'subject', 20),
            ('date', 'postdate'),
            ('category', 'category.name'),
            ('post_id', 'id'),
            ('category_id', 'category.id'),
            ('group_id', 'category.group.id'),
        ]

    space.add_index(Post, PostIndexer, attach_as='indexer')
except:
    pass
示例#18
0
文件: models.py 项目: fanboi/snippify
	""" Django comment framework sucks! """
	snippet = models.ForeignKey(Snippet)
	user = models.ForeignKey(User)
	body = models.TextField()
	created_date = models.DateTimeField(default=datetime.now())
	class Meta:
		ordering = ['created_date']
class SnippetVersion(models.Model):
	""" History for snippets! """
	snippet = models.ForeignKey(Snippet)
	version = models.IntegerField(default = 1)
	body = models.TextField()
	created_date = models.DateTimeField(default=datetime.now())
	class Meta:
		ordering = ['-version']
class SnippetIndexer(Indexer):
	""" Used by djapian """
	fields = ['title', 'description', 'body', 'tags', 'lexer']
	tags = [
		('author', 'author'),
		('pk', 'pk'),
		('created_date', 'created_date')
	]
class TagIndexer(Indexer):
	""" Used by djapian """
	fields = ['name']
	tags = [
		('name', 'name')
	]
space.add_index(Snippet, SnippetIndexer, attach_as='indexer')
space.add_index(Tag, TagIndexer, attach_as='indexer')
示例#19
0
文件: index.py 项目: heldergg/dre
    def related(self, article):
        PUNCTUATION = ",. \n\t\\\"'][#*:()"

        words = article.split()
        words = list(set([ word.strip(PUNCTUATION) for word in words ]))

        query = xapian.Query( xapian.Query.OP_ELITE_SET, words)

        return self.search( query, parse_query = False).prefetch()

    def relevant(self, rsetids, word_number = 40):
        database = self._db.open()
        enquire = xapian.Enquire(database)
        rset = xapian.RSet()

        if  isinstance(rsetids, list):
            for docid in rsetids:
                rset.add_document(docid)
        else:
            rset.add_document(rsetids)

        eset = enquire.get_eset(word_number, rset)

        query = xapian.Query( xapian.Query.OP_OR,
                    [ eset_item.term for eset_item in eset ])

        return self.search( query, parse_query = False).prefetch()

space.add_index(Document, DocumentIndexer, attach_as='indexer')
示例#20
0
from djapian import space, Indexer
from sjphoto.base.models import Gallery


class GalleryIndexer(Indexer):
    fields = ['title', 'description']
    tags = [('title', 'title', 3), ('description', 'description', 2)]


space.add_index(Gallery, GalleryIndexer, attach_as="indexer")
示例#21
0
"""
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)
    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)
try:
    from djapian import space, Indexer
    from sphene.sphboard.models import Post

    class PostIndexer(Indexer):
        fields = [('subject', 20), 'body']
        tags = [
            ('subject', 'subject', 20),
            ('date', 'postdate'),
            ('category', 'category.name'),
            ('post_id', 'id'),
            ('category_id', 'category.id'),
            ('group_id', 'category.group.id'),
          ]

    space.add_index(Post, PostIndexer, attach_as='indexer')
except:
    pass


    
示例#24
0
from djapian import space, Indexer, CompositeIndexer
import logging
from search.models import DocumentSurrogate

class DocumentIndexer(Indexer):
    fields = ['title', 'summary', 'text']
    #TODO: add the date tag, to do an order_by and stuff    
    tags = [
            ('title', 'title', 3),
            ('summary', 'summary',2),
            ('text', 'text'),
            ]

space.add_index(DocumentSurrogate, DocumentIndexer, attach_as='indexer')

#try:
#    DocumentSurrogate.indexer.update()
#except Exception, e:
#    logging.error("Error updating index", exc_info=True)
示例#25
0
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)