# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from netadmin.networks.models import Host, Network try: import search from search.core import startswith search.register(Host, ('name', 'description', 'ipv4', 'ipv6'), indexer=startswith) search.register(Network, ('name', 'description'), indexer=startswith) except ImportError: from haystack import indexes from haystack import site class HostIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) def index_queryset(self): return Host.objects.all() class NetworkIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True)
# Copyright 2015 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import search from search.core import startswith from main.models import Box search.register(Box, ('title', ), indexer=startswith, search_index='autocomplete_index')
return self.name class Indexed(models.Model): extra_data = models.ForeignKey(ExtraData, related_name='indexed_model', null=True) extra_data2 = models.ForeignKey(ExtraData, null=True) # Test normal and prefix index one = models.CharField(max_length=500, null=True) two = models.CharField(max_length=500) check = models.BooleanField() value = models.CharField(max_length=500) def __unicode__(self): return ':'.join((repr(self.one), repr(self.two), repr(self.check), repr(self.value))) register(Indexed, 'one', search_index='one_index', indexer=startswith) register(Indexed, ('one', 'two'), search_index='one_two_index') register(Indexed, 'value', integrate=('one', 'check'), search_index='value_index') # Test filters class FiltersIndexed(models.Model): value = models.CharField(max_length=500) check = models.BooleanField() register(FiltersIndexed, 'value', filters={'check':True, }, search_index='checked_index') class TestIndexed(TestCase): def setUp(self): extra_data = ExtraData() extra_data.save()
import search from search.core import porter_stemmer from posts.models import Entry for item in Entry.live.all(): item.save() search.register(Entry, ('title','body_html', 'meta_description', 'meta_keywords'), indexer=porter_stemmer)
import search from search.core import porter_stemmer_non_stop from biblioteca.models import Book, Writer search.register(Book, ('title', 'publisher','isbn', 'year', 'authors', ), indexer=porter_stemmer_non_stop)
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2011 Adriano Monteiro Marques # # Author: Piotrek Wasilewski <*****@*****.**> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import search from search.core import startswith from models import Event search.register(Event, ('short_message', 'message'), indexer=startswith)
# post.search_indexes import search from search.core import porter_stemmer from search.core import startswith from wc.models import Organization from wc.models import Person from wc.models import Crisis # index used to retrieve posts using the title, content or the # category. # porter stemmer search.register(Organization, ('name', 'kind', 'address', 'phone', 'email'), indexer=porter_stemmer, search_index='organization_level1') search.register(Organization, ('history', 'description', 'city', 'state', 'country'), indexer=porter_stemmer, search_index='organization_level2') search.register(Organization, ('relatedkeywords'), indexer=porter_stemmer, search_index='organization_level3') search.register(Person, ('name', 'kind'), indexer=porter_stemmer, search_index='person_level1') search.register(Person, ('description', 'city', 'state', 'country'), indexer=porter_stemmer, search_index='person_level2') search.register(Person, ('relatedkeywords'), indexer=porter_stemmer, search_index='person_level3') search.register(Crisis, ('name', 'kind'), indexer=porter_stemmer, search_index='crisis_level1')
import search from ..events.search_indexes import indexer, splitter from .models import Task search.register(Task, ('name', ), indexer=indexer, splitter=splitter, search_index='search_index_name') search.register(Task, ('name', 'description', ), indexer=indexer, splitter=splitter)
# it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from models import Event try: import search from search.core import startswith search.register(Event, ('short_message', 'message'), indexer=startswith) except ImportError: from haystack import indexes from haystack import site class EventIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) def index_queryset(self): return Event.objects.all() site.register(Event, EventIndex)
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2011 Adriano Monteiro Marques # # Author: Piotrek Wasilewski <*****@*****.**> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import search from search.core import startswith from django.contrib.auth.models import User search.register(User, ('username', 'first_name', 'last_name'), indexer=startswith)
import search from search.core import porter_stemmer_non_stop from flashcards.models import * search.register(Card, ('front', ), indexer=porter_stemmer_non_stop, search_index="front_search") search.register(Card, ('back', ), indexer=porter_stemmer_non_stop, search_index="back_search") search.register(CardTagView, ('denormalized_searchable_name', ), indexer=porter_stemmer_non_stop) search.register(CardSourceView, ('denormalized_searchable_name'), indexer=porter_stemmer_non_stop, search_index='name_search') search.register(CardSourceView, ('text'), indexer=porter_stemmer_non_stop, search_index='text_search')
import search from ..events.search_indexes import indexer, splitter from .models import User search.register(User, ('email', 'first_name','last_name', ), indexer=indexer, splitter=splitter)
import search from search.core import porter_stemmer, startswith from ias.models import Taxon, Sighting search.register(Taxon, ('scientific_name', 'common_name', 'rank'), indexer=startswith, search_index='startswith_index') search.register(Taxon, ('scientific_name', 'common_name', 'rank'), indexer=porter_stemmer, search_index='porterstemmer_index') search.register(Sighting, ('email', 'taxon_name'), indexer=startswith, search_index='startswith_index') search.register(Sighting, ('email', 'taxon_name'), indexer=porter_stemmer, search_index='porterstemmer_index')
# bid.search_indexes import search from search.core import porter_stemmer from core.models import Bid # index used to retrieve Bids using the product search.register(Bid, ('product'),indexer=porter_stemmer)
""" search_indexes.py Setup required indexes to allow the search module to perform searches on the Post model. """ import search from search.core import porter_stemmer from blog.models import Post # Create indexes on title and text fields. search.register( Post, ('title', 'text', ), indexer=porter_stemmer)
from unidecode import unidecode import search from search.core import default_splitter from .models import Event def indexer(words, language, **kwargs): result = [] for word in words: uniword = unidecode(word) result.append(uniword) if len(uniword) > 2: for i in range (3, len(uniword)): result.append(uniword[0:i]) return result def splitter(text, indexing=False, **kwargs): return default_splitter(unidecode(text), indexing, **kwargs) search.register(Event, ('name', ), indexer=indexer, splitter=splitter, search_index='search_index_name') search.register(Event, ('name', 'description','keywords', 'result', ), indexer=indexer, splitter=splitter)
related_name='indexed_model', null=True) extra_data2 = models.ForeignKey(ExtraData, null=True) # Test normal and prefix index one = models.CharField(max_length=500, null=True) two = models.CharField(max_length=500) check = models.BooleanField() value = models.CharField(max_length=500) def __unicode__(self): return ':'.join((repr(self.one), repr(self.two), repr(self.check), repr(self.value))) register(Indexed, 'one', search_index='one_index', indexer=startswith) register(Indexed, ('one', 'two'), search_index='one_two_index') register(Indexed, 'value', integrate=('one', 'check'), search_index='value_index') # Test filters class FiltersIndexed(models.Model): value = models.CharField(max_length=500) check = models.BooleanField() register(FiltersIndexed, 'value',
# published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from django.contrib.auth.models import User try: import search from search.core import startswith search.register(User, ('username', 'first_name', 'last_name'), indexer=startswith) except ImportError: from haystack import indexes from haystack import site class UserIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) def index_queryset(self): return User.objects.all() site.register(User, UserIndex)
import search from search.core import porter_stemmer_non_stop from flashcards.models import * search.register(Card, ('front',), indexer=porter_stemmer_non_stop, search_index="front_search") search.register(Card, ('back',), indexer=porter_stemmer_non_stop, search_index="back_search") search.register(CardTagView, ('denormalized_searchable_name',), indexer=porter_stemmer_non_stop) search.register(CardSourceView, ('denormalized_searchable_name'), indexer=porter_stemmer_non_stop, search_index='name_search') search.register(CardSourceView, ('text'), indexer=porter_stemmer_non_stop, search_index='text_search')