public async Task GlobalSetup()
        {
            _path = Guid.NewGuid().ToString();

            var plain = await PlainIndex();

            _lmdb = new LmdbIndex(_path);

            foreach (var field in plain.Fields)
            {
                _lmdb.AddField(field);
            }

            foreach (var(k, v) in plain.FieldVectors)
            {
                _lmdb.AddFieldVector(k, v);
            }

            foreach (var(k, v) in plain.InvertedIndex)
            {
                _lmdb.AddInvertedIndexEntry(k, v);
            }

            Index = new DelegatedIndex(_lmdb, plain.Pipeline);
        }
Esempio n. 2
0
        private DelegatedIndex CopyIndex(Lunr.Index index)
        {
            var path = _tempDir.NewDirectory();

            var lmdb = new LmdbIndex(path);

            foreach (var field in index.Fields)
            {
                Assert.True(lmdb.AddField(field));
            }

            foreach (var(k, v) in index.FieldVectors)
            {
                Assert.True(lmdb.AddFieldVector(k, v));
            }

            foreach (var(k, v) in index.InvertedIndex)
            {
                Assert.True(lmdb.AddInvertedIndexEntry(k, v));
            }

            var idx = new DelegatedIndex(lmdb, index.Pipeline);

            return(idx);
        }
        public void Can_persist_fields()
        {
            const string field = "Field";

            using var index = new LmdbIndex(_tempDir.NewDirectory());

            var addedField = index.AddField(field);

            Assert.True(addedField);

            var fields = index.GetFields();

            Assert.NotNull(fields);
            Assert.Equal(field, fields.Single());

            var removedField = index.RemoveField(field);

            Assert.True(removedField);

            var noFields = index.GetFields();

            Assert.NotNull(fields);
            Assert.Empty(noFields);
        }