# Path: entity/recipe.py
# class Recipe:
#     def __init__(self, categories=[], description='', id=None, info='',
#                  ingredients='', rating=None, serving_size='', title='',
#                  tags=[], urls=[], synonyms=[], images=[], author=None):
#     def __str__(self):
#     def count_all(db):
#     def delete(self, db):
#     def find_all(db):
#     def find_category(db, category):
#     def find_pk(db, id):
#     def find_random(db, num):
#     def from_row(db, row):
#     def is_new(self):
#     def title_exists(db, title):
#     def save(self, db):
#     def __delete_images(self, db, force=False):
#     def __delete_recipe_has_category(self, db):
#     def __delete_recipe_has_tag(self, db):
#     def __delete_synonyms(self, db):
#     def __delete_urls(self, db):
#     def __generic_find(db, query, params):


from entity import recipe as recipe_entity
from whoosh import qparser
#!/usr/bin/python
# -*- coding: utf-8 -*-


class Searcher:
    """ Searcher class.

    Constants:
    DEFAULT_FIELD -- Name of the default field to search (string).

    Member:
    _indexer -- The indexer (indexer).
    """

    DEFAULT_FIELD = 'titletags'

    def __init__(self, indexer):
        self._indexer = indexer

    def search(self, db, query_text):
        """ Search this query. Returns found recipes. """
        parser = qparser.QueryParser(self.DEFAULT_FIELD, self._indexer.scheme())
        query = parser.parse(query_text)
        recipes = []
        with self._indexer.searcher() as searcher:
            results = searcher.search(query, limit=None)
            if results:
                for hit in results:

# Path: entity/recipe.py
# class Recipe:
#     def __init__(self, categories=[], description='', id=None, info='',
#                  ingredients='', rating=None, serving_size='', title='',
#                  tags=[], urls=[], synonyms=[], images=[], author=None):
#     def __str__(self):
#     def count_all(db):
#     def delete(self, db):
#     def find_all(db):
#     def find_category(db, category):
#     def find_pk(db, id):
#     def find_random(db, num):
#     def from_row(db, row):
#     def is_new(self):
#     def title_exists(db, title):
#     def save(self, db):
#     def __delete_images(self, db, force=False):
#     def __delete_recipe_has_category(self, db):
#     def __delete_recipe_has_tag(self, db):
#     def __delete_synonyms(self, db):
#     def __delete_urls(self, db):
#     def __generic_find(db, query, params):


# Path: search/searcher.py
from entity import recipe as recipe_entity
from whoosh import qparser

#!/usr/bin/python
# -*- coding: utf-8 -*-


class Searcher:
    """ Searcher class.

    Constants:
    DEFAULT_FIELD -- Name of the default field to search (string).

    Member:
    _indexer -- The indexer (indexer).
    """

    DEFAULT_FIELD = 'titletags'

    def __init__(self, indexer):
        self._indexer = indexer

    def search(self, db, query_text):
        """ Search this query. Returns found recipes. """
        parser = qparser.QueryParser(self.DEFAULT_FIELD, self._indexer.scheme())
        query = parser.parse(query_text)
        recipes = []
        with self._indexer.searcher() as searcher:
            results = searcher.search(query, limit=None)
            if results:
                for hit in results:

                    recipe = recipe_entity.Recipe.find_pk(db, hit['id'])