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);
        }
        public async Task FieldContainsTermsThatClashWithObjectPrototype()
        {
            var builder = new LmdbBuilder();

            builder.AddField("title");

            await builder.Add(new Document
            {
                { "id", "id" },
                { "title", "constructor" }
            });

            using var index = builder.Build(_tempDir.NewDirectory());

            Assert.Empty(index.GetInvertedIndexEntryByKey("constructor") !["title"]["id"]);