aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/test/schema_builder.h
blob: 9ac152fc6c59ffad3e0b844b9d9f32cc5a4a8d7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcommon/common/schema.h>
#include <vespa/vespalib/stllike/string.h>
#include <memory>
#include <optional>
#include <vector>

namespace search::test {

class DocBuilder;

/*
 * Class used to make schema based on document type.
 */
class SchemaBuilder {
    const DocBuilder& _doc_builder;
    std::unique_ptr<search::index::Schema> _schema;
    void add_index(vespalib::stringref field_name, std::optional<bool> interleaved_features);
    void add_attribute(vespalib::stringref field_name);
public:
    SchemaBuilder(const DocBuilder& doc_builder);
    ~SchemaBuilder();
    SchemaBuilder& add_indexes(std::vector<vespalib::stringref> field_names, std::optional<bool> interleaved_features = std::nullopt);
    SchemaBuilder& add_all_indexes(std::optional<bool> interleaved_features = std::nullopt);
    SchemaBuilder& add_attributes(std::vector<vespalib::stringref> field_names);
    SchemaBuilder& add_all_attributes();
    search::index::Schema build();
};

}