diff options
author | Kristian Aune <kkraune@users.noreply.github.com> | 2020-08-11 11:52:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 11:52:03 +0200 |
commit | d197fb24a9f40ff0dd6699bb448dd61785683e63 (patch) | |
tree | 0f4f67721d17edfaf9becb7601090cccffcc07da /config-model | |
parent | ced0bc98f39c62add1a2ec533038ffc75370d026 (diff) | |
parent | 388c84882dcf133afbb46f138679201a2e38d58e (diff) |
Merge pull request #12938 from vespa-engine/kkraune/schema
use schema
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/python/ES_Vespa_parser.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/config-model/src/main/python/ES_Vespa_parser.py b/config-model/src/main/python/ES_Vespa_parser.py index deebb1d6973..c695aae9fcb 100644 --- a/config-model/src/main/python/ES_Vespa_parser.py +++ b/config-model/src/main/python/ES_Vespa_parser.py @@ -13,7 +13,7 @@ class ElasticSearchParser: document_file = None mapping_file = None application_name = None - search_definitions = {} + schemas = {} path = "" _all = True all_mappings = {} @@ -40,10 +40,10 @@ class ElasticSearchParser: print(" > Folder '" + self.path + "' already existed") try: - os.makedirs(self.path + "searchdefinitions/", 0o777) - print(" > Created folder '" + self.path + "searchdefinitions/" + "'") + os.makedirs(self.path + "schemas/", 0o777) + print(" > Created folder '" + self.path + "schemas/" + "'") except OSError: - print(" > Folder '" + self.path + "searchdefinitions/" + "' already existed") + print(" > Folder '" + self.path + "schemas/" + "' already existed") self.parse() self.createServices_xml() @@ -62,17 +62,17 @@ class ElasticSearchParser: _all_enabled = data[index]["mappings"][type]["_all"]["enabled"] if not _all_enabled: self._all = False - print(" > Not all fields in the document type '" + type + "' are searchable. Edit " + self.path + "searchdefinitions/" + type + ".sd to control which fields are searchable") + print(" > Not all fields in the document type '" + type + "' are searchable. Edit " + self.path + "schemas/" + type + ".sd to control which fields are searchable") except KeyError: print(" > All fields in the document type '" + type + "' is searchable") self.walk(mappings, type_mapping, "properties") unparsed_mapping_file.close() - if type not in self.search_definitions: - self.search_definitions[type] = True + if type not in self.schemas: + self.schemas[type] = True self.types.append(type) - self.createSearchDefinition(type, type_mapping) + self.createSchema(type, type_mapping) # Adding mapping to global map with mappings self.all_mappings[type] = type_mapping @@ -111,8 +111,8 @@ class ElasticSearchParser: unparsed_document_file.close() print(" > Parsed all documents '" + ", ".join(self.types) + "' at '" + file_path + "'") - def createSearchDefinition(self, type, type_mapping): - file_path = self.path + "searchdefinitions/" + type + ".sd" + def createSchema(self, type, type_mapping): + file_path = self.path + "schemas/" + type + ".sd" new_sd = open(file_path, "w") new_sd.write("search " + type + " {\n") new_sd.write(" document " + type + " {\n") @@ -129,7 +129,7 @@ class ElasticSearchParser: new_sd.write(" }\n") new_sd.write("}\n") new_sd.close() - print(" > Created search definition for '" + type + "' at '" + file_path + "'") + print(" > Created schema for '" + type + "' at '" + file_path + "'") def createServices_xml(self): file_path = self.path + "services.xml" @@ -225,6 +225,5 @@ class ElasticSearchParser: if item == "no": # Field should not be searchable self.no_index.append(parent) - if __name__ == '__main__': ElasticSearchParser().main() |