Beispiel #1
0
    def test_everything(self):

        # In memory catalog
        cat = make_catalog(None, Document_2.fields)

        # Some data
        cat.index_document(
            Document_2(
                1, {
                    'en': u'Hello world',
                    'fr': u'Bonjour le monde',
                    'de': u'Hallo Welt',
                    'es': u'Hola mundo'
                }))
        cat.index_document(
            Document_2(2, {
                'fr': u'Albert et le monde',
                'en': u'Albert and the world'
            }))
        cat.index_document(Document_2(3, u'world'))

        # A simple search
        self.assertEqual(len(cat.search(data=u'world')), 3)
        self.assertEqual(len(cat.search(data=u'monde')), 2)
        self.assertEqual(len(cat.search(data_de=u'welt')), 1)
        self.assertEqual(len(cat.search(data_en=u'welt')), 0)

        # Sort & Value
        result = cat.search(data=u'monde')
        doc1, doc2 = result.get_documents(sort_by='data_fr')
        self.assertEqual(doc1.data_en, u'Albert and the world')
        self.assertEqual(doc2.data_es, u'Hola mundo')
Beispiel #2
0
    def test_everything(self):

        # In memory catalog
        cat = make_catalog(None, Document_2.fields)

        # Some data
        cat.index_document(Document_2(1, {'en': u'Hello world',
                                          'fr': u'Bonjour le monde',
                                          'de': u'Hallo Welt',
                                          'es': u'Hola mundo'}))
        cat.index_document(Document_2(2, {'fr': u'Albert et le monde',
                                          'en': u'Albert and the world'}))
        cat.index_document(Document_2(3, u'world'))

        # A simple search
        self.assertEqual(len(cat.search(data=u'world')), 3)
        self.assertEqual(len(cat.search(data=u'monde')), 2)
        self.assertEqual(len(cat.search(data_de=u'welt')), 1)
        self.assertEqual(len(cat.search(data_en=u'welt')), 0)


        # Sort & Value
        result = cat.search(data=u'monde')
        doc1, doc2 = result.get_documents(sort_by='data_fr')
        self.assertEqual(doc1.data_en, u'Albert and the world')
        self.assertEqual(doc2.data_es, u'Hola mundo')
Beispiel #3
0
 def setUp(self):
     # Make the catalog
     catalog = make_catalog('tests/catalog', Document.fields)
     # Index
     fables = lfs.open('fables')
     for name in fables.get_names():
         abspath = fables.get_absolute_path(name)
         document = Document(abspath)
         catalog.index_document(document)
     # Save
     catalog.save_changes()
Beispiel #4
0
    def reset(self):
        self.properties = {}
        self.components = {}

        # A Catalog "in memory"
        fields = {'__uid__': String(is_key_field=True, is_stored=True,
                                    is_indexed=True),
                  'type': String(is_indexed=True),
                  'dtstart': DateTime(is_stored=True, is_indexed=True),
                  'dtend': DateTime(is_stored=True, is_indexed=True)}
        self.catalog = make_catalog(None, fields)
Beispiel #5
0
 def setUp(self):
     # Make the catalog
     catalog = make_catalog('tests/catalog', Document.fields)
     # Index
     fables = lfs.open('fables')
     for name in fables.get_names():
         abspath = fables.get_absolute_path(name)
         document = Document(abspath)
         catalog.index_document(document)
     # Save
     catalog.save_changes()
Beispiel #6
0
 def reset(self):
     self.properties = None
     self.records = []
     self.added_properties = []
     self.added_records = []
     self.removed_records = []
     # The catalog (for index and search)
     fields = merge_dicts(
         self.record_properties,
         __id__=Integer(is_key_field=True, is_stored=True, is_indexed=True))
     self.catalog = make_catalog(None, fields)
Beispiel #7
0
 def reset(self):
     self.properties = None
     self.records = []
     self.added_properties = []
     self.added_records = []
     self.removed_records = []
     # The catalog (for index and search)
     fields = merge_dicts(self.record_properties,
                          __id__=Integer(is_key_field=True,
                                         is_stored=True,
                                         is_indexed=True))
     self.catalog = make_catalog(None, fields)
Beispiel #8
0
    def reset(self):
        self.properties = {}
        self.components = {}

        # A Catalog "in memory"
        fields = {
            '__uid__': String(is_key_field=True,
                              is_stored=True,
                              is_indexed=True),
            'type': String(is_indexed=True),
            'dtstart': DateTime(is_stored=True, is_indexed=True),
            'dtend': DateTime(is_stored=True, is_indexed=True)
        }
        self.catalog = make_catalog(None, fields)
Beispiel #9
0
 def reset(self):
     self.lines = []
     self.n_lines = 0
     # Initialize the catalog if needed (Index&Search)
     # (we look if we have at least one indexed field in schema/columns)
     self.catalog = None
     schema = self.schema
     if schema is not None:
         for name in self.columns:
             field_cls = schema[name]
             if getattr(field_cls, 'is_indexed', False):
                 fields = merge_dicts(schema,
                                      __number__=Integer(is_key_field=True,
                                                         is_stored=True,
                                                         is_indexed=True))
                 self.catalog = make_catalog(None, fields)
                 break
Beispiel #10
0
 def reset(self):
     self.lines = []
     self.n_lines = 0
     # Initialize the catalog if needed (Index&Search)
     # (we look if we have at least one indexed field in schema/columns)
     self.catalog = None
     schema = self.schema
     if schema is not None:
         for name in self.columns:
             field_cls = schema[name]
             if getattr(field_cls, 'is_indexed', False):
                 fields = merge_dicts(schema,
                                      __number__=Integer(is_key_field=True,
                                                         is_stored=True,
                                                         is_indexed=True))
                 self.catalog = make_catalog(None, fields)
                 break
Beispiel #11
0
    def test_everything(self):

        # In memory catalog
        cat = make_catalog(None, Document_2.fields)

        # Some data
        cat.index_document(Document_2(1, u'foo à €'))
        cat.index_document(Document_2(2, u'aabà'))
        cat.index_document(Document_2(3, u'aabàà'))
        cat.index_document(Document_2(4, u'aac'))

        # A simple search
        self.assertEqual(len(cat.search(data=u'à')),1)

        # Start
        q = StartQuery('data', u'aabà')
        r = [ doc.id for doc in cat.search(q).get_documents() ]
        self.assertEqual(r, [2, 3])
Beispiel #12
0
    def test_everything(self):

        # In memory catalog
        cat = make_catalog(None, Document_2.fields)

        # Some data
        cat.index_document(Document_2(1, u'foo à €'))
        cat.index_document(Document_2(2, u'aabà'))
        cat.index_document(Document_2(3, u'aabàà'))
        cat.index_document(Document_2(4, u'aac'))

        # A simple search
        self.assertEqual(len(cat.search(data=u'à')), 1)

        # Start
        q = StartQuery('data', u'aabà')
        r = [doc.id for doc in cat.search(q).get_documents()]
        self.assertEqual(r, [2, 3])