gyllstromk/Flask-WhooshAlchemy — pull request #24 by ssherar (2014-06-02 09:36:14+00:00)
Title: Feature implementation: Custom analyzers

Aloha!

I working on a project which required a `Metaphone` filter added to the fulltext search due to the average spelling mistakes, so I thought I would implement it in an style which fits closely with the module in hand.

```python
from whoosh.analysis import StemmingAnalyzer, DoubleMetaphoneFilter

class Table(db.Model):
__tablename__ = "test"
__searchable__ = ["field1", "field2"]
__analyzer__ = StemmingAnalyzer() | DoubleMetaphoneFilter()
```

The logic behind this, albeit basic, is using the inbuilt `getattr` for a fallback to the standard `StemmingAnalyzer` which you have defaulted everything to.

I understand that PR #17 has already implemented a solution to this, but this should give a more systemic approach to users utilizing the library and give them the ability to add custom analyzers for different tables being indexed by Whoosh.