'Test searching returns the same data for both backends'

def test_searching(self):

    from calibre.library.database2 import LibraryDatabase2
    old = LibraryDatabase2(self.library_path)
    oldvals = {query: set(old.search_getting_ids(query, u'')) for query in (u'date:9/6/2011', u'date:true', u'date:false', u'pubdate:1/9/2011', u'#date:true', u'date:<100daysago', u'date:>9/6/2011', u'#date:>9/1/2011', u'#date:=2011', u'rating:3', u'rating:>2', u'rating:=2', u'rating:true', u'rating:false', u'rating:>4', u'tags:#<2', u'tags:#>7', u'cover:false', u'cover:true', u'#float:>11', u'#float:<1k', u'#float:10.01', u'#float:false', u'series_index:1', u'series_index:<3', u'#yesno:true', u'#yesno:false', u'#yesno:yes', u'#yesno:no', u'#yesno:empty', u'identifiers:true', u'identifiers:false', u'identifiers:test', u'identifiers:test:false', u'identifiers:test:one', u'identifiers:t:n', u'identifiers:=test:=two', u'identifiers:x:y', u'identifiers:z', u'title:="Title    One"', u'title:~title', u'#enum:=one', u'#enum:tw', u'#enum:false', u'#enum:true', u'series:one', u'tags:one', u'tags:true', u'tags:false', u'uuid:2', u'one', u'20.02', u'"publisher    one"', u'"my    comments    one"', u'series_sort:one', u'@Good    Authors:One', u'@Good    Series.good    tags:two', u'cover:true', u'cover:false', u'formats:true', u'formats:false', u'formats:#>1', u'formats:#=1', u'formats:=fmt1', u'formats:=fmt2', u'formats:=fmt1    or    formats:fmt2', u'#formats:true', u'#formats:false', u'#formats:fmt1', u'#formats:fmt2', u'#formats:fmt1    and    #formats:fmt2')}
    old.conn.close()
    old = None
    cache = self.init_cache(self.cloned_library)
    for (query, ans) in oldvals.iteritems():
        nr = cache.search(query, u'')
        self.assertEqual(ans, nr, (u'Old    result:    %r    !=    New    result:    %r    for    search:    %s' % (ans, nr, query)))
    self.assertEqual(cache.search(u'id:1', u''), {1})
    self.assertEqual(cache.search(u'id:>1', u''), {2, 3})
    cache.set_field(u'rating', {1: 4, 2: 2, 3: 5})
    self.assertEqual(cache.search(u'rating:>2'), set())
    self.assertEqual(cache.search(u'rating:>=2'), {1, 3})
    self.assertEqual(cache.search(u'rating:<2'), {2})
    self.assertEqual(cache.search(u'rating:<=2'), {1, 2, 3})
    self.assertEqual(cache.search(u'rating:<=2'), {1, 2, 3})
    self.assertEqual(cache.search(u'rating:=2'), {1, 3})
    self.assertEqual(cache.search(u'rating:2'), {1, 3})
    self.assertEqual(cache.search(u'rating:!=2'), {2})
    cache.field_metadata.all_metadata()[u'#rating'][u'display'][u'allow_half_stars'] = True
    cache.set_field(u'#rating', {1: 3, 2: 4, 3: 9})
    self.assertEqual(cache.search(u'#rating:1'), set())
    self.assertEqual(cache.search(u'#rating:1.5'), {1})
    self.assertEqual(cache.search(u'#rating:>4'), {3})
    self.assertEqual(cache.search(u'#rating:2'), {2})
