Each and every Model which is Eligible for search has
1. Search Schema and Search Key which is used by Haystack and Whoosh to do the Searching
Example
```
search_schema = ('fullname', )
search_key = 'name'
```
2. The search is carried out on the dields mention in the file apps/search_indexes.py
```
class AppIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.EdgeNgramField(document = True, use_template = True)
Bundle_Name = indexes.CharField(model_attr='Bundle_Name',null=True)
categories = indexes.MultiValueField(model_attr = 'categories', null=True)
stars = indexes.IntegerField(model_attr = 'stars',null = True)
def get_model(self):
return App
def prepare_tags(self, obj):
return [tag.id for tag in obj.categories.all()]
```
3. Search Template can be located at templates/search/indexes/apps/app_text.txt
This file is responsible to handle the Indexing part of the Search when the app is first added to the search index by Whoosh
```
{{ object.Bundle_Name }}
{{ object.downloads }}
{{ object.stars }}
{% for tag in object.app.categories.all %}
{{ tag.name }}
{% endfor %}
```
Searching can be done on more specific fields if we figure out how the search indexing works and then addig it to Releases model rather than Apps model.
Each and every Model which is Eligible for search has
1. Search Schema and Search Key which is used by Haystack and Whoosh to do the Searching
Example
```
search_schema = ('fullname', )
search_key = 'name'
```
2. The search is carried out on the dields mention in the file apps/search_indexes.py
```
class AppIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.EdgeNgramField(document = True, use_template = True)
Bundle_Name = indexes.CharField(model_attr='Bundle_Name',null=True)
categories = indexes.MultiValueField(model_attr = 'categories', null=True)
stars = indexes.IntegerField(model_attr = 'stars',null = True)
def get_model(self):
return App
def prepare_tags(self, obj):
return [tag.id for tag in obj.categories.all()]
```
3. Search Template can be located at templates/search/indexes/apps/app_text.txt
This file is responsible to handle the Indexing part of the Search when the app is first added to the search index by Whoosh
```
{% for tag in object.app.categories.all %}{{ object.Bundle_Name }}
{{ object.downloads }}
{{ object.stars }}
{{ tag.name }}
{% endfor %}```
Searching can be done on more specific fields if we figure out how the search indexing works and then addig it to Releases model rather than Apps model.