app/views/search.py
def search(self, **kwargs):
        """
        Finds the top item matching the arguments.
            query(str): the text being searched for
            name(list): The names of the item
            desc(list): The data to search the defn and desc fields for
            type(list): the expected type of the item (class names)
        """
        kwargs = defaultdict(unicode, **kwargs)
        with self.index.searcher() as searcher:
            query = (QueryParser('keywords', self.index.schema)
                .parse(unicode(kwargs.get('query', u'').lower()))
            )

            if not kwargs['name'] is None:
                query = (query & QueryParser(u'name', self.index.schema)
                    .parse(" ".join([
                        unicode(i) for i in kwargs['name']
                    ]))
                )
            if not kwargs['desc'] is None:
                query = (query
                    & MultifieldParser([u'desc', u'defn'], self.index.schema)
                        .parse(" ".join([
                            unicode(i) for i in kwargs['desc']
                        ]))
                )

            if not kwargs['type'] is None:
                query = (
                    QueryParser(u'type', self.index.schema, group=OrGroup).parse(" ".join(kwargs['type']))
                    & query
                )

            print query

            page = searcher.search_page(
                query,
                kwargs.get('page', 1), pagelen=kwargs.get('pagelen', 10)
            )
            return {
                'pages': page.pagecount,
                'page': page.pagenum,
                'total': page.total,
                'results': [hit.fields() for hit in page.results]
            }

        Finds the top item matching the arguments.
            query(str): the text being searched for
            name(list): The names of the item
            desc(list): The data to search the defn and desc fields for
            type(list): the expected type of the item (class names)
        
Finds the top item matching the arguments.
query(str): the text being searched for
name(list): The names of the item
desc(list): The data to search the defn and desc fields for
type(list): the expected type of the item (class names)
Finds the top item matching the arguments . query ( str ) : the text being searched for name ( list ) : The names of the item desc ( list ) : The data to search the defn and desc fields for type ( list ) : the expected type of the item ( class names )
def search(self, **kwargs):
        kwargs = defaultdict(unicode, **kwargs)
        with self.index.searcher() as searcher:
            query = (QueryParser('keywords', self.index.schema)
                .parse(unicode(kwargs.get('query', u'').lower()))
            )
            if not kwargs['name'] is None:
                query = (query & QueryParser(u'name', self.index.schema)
                    .parse(" ".join([
                        unicode(i) for i in kwargs['name']
                    ]))
                )
            if not kwargs['desc'] is None:
                query = (query
                    & MultifieldParser([u'desc', u'defn'], self.index.schema)
                        .parse(" ".join([
                            unicode(i) for i in kwargs['desc']
                        ]))
                )
            if not kwargs['type'] is None:
                query = (
                    QueryParser(u'type', self.index.schema, group=OrGroup).parse(" ".join(kwargs['type']))
                    & query
                )
            print query
            page = searcher.search_page(
                query,
                kwargs.get('page', 1), pagelen=kwargs.get('pagelen', 10)
            )
            return {
                'pages': page.pagecount,
                'page': page.pagenum,
                'total': page.total,
                'results': [hit.fields() for hit in page.results]
            }
def search ( self , ** kwargs ) : kwargs = defaultdict ( unicode , ** kwargs ) with self . index . searcher ( ) as searcher : query = ( QueryParser ( 'keywords' , self . index . schema ) . parse ( unicode ( kwargs . get ( 'query' , u'' ) . lower ( ) ) ) ) if not kwargs [ 'name' ] is None : query = ( query & QueryParser ( u'name' , self . index . schema ) . parse ( " " . join ( [ unicode ( i ) for i in kwargs [ 'name' ] ] ) ) ) if not kwargs [ 'desc' ] is None : query = ( query & MultifieldParser ( [ u'desc' , u'defn' ] , self . index . schema ) . parse ( " " . join ( [ unicode ( i ) for i in kwargs [ 'desc' ] ] ) ) ) if not kwargs [ 'type' ] is None : query = ( QueryParser ( u'type' , self . index . schema , group = OrGroup ) . parse ( " " . join ( kwargs [ 'type' ] ) ) & query ) print query page = searcher . search_page ( query , kwargs . get ( 'page' , 1 ) , pagelen = kwargs . get ( 'pagelen' , 10 ) ) return { 'pages' : page . pagecount , 'page' : page . pagenum , 'total' : page . total , 'results' : [ hit . fields ( ) for hit in page . results ] }
Finds the top item matching the arguments.
Finds the top item matching the arguments .
"""
        Finds the top item matching the arguments.
            query(str): the text being searched for
            name(list): The names of the item
            desc(list): The data to search the defn and desc fields for
            type(list): the expected type of the item (class names)
        """
self