diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-10-15 19:00:17 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-10-15 19:00:17 +0200 |
commit | cf7c0cb612a2cbc1cd63e7043eae28e5a5ecba06 (patch) | |
tree | 38309e09d8ec0f4ebbf702343b3f0a7590dbcaa1 /config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java | |
parent | 813c270c2ea80953c7b09aac56dc6a5c254aca1e (diff) |
search -> schema
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java index adfed2e8147..91ff9040713 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java @@ -37,7 +37,7 @@ import java.util.LinkedList; import java.util.List; /** - * Helper class for importing {@link Search} objects in an unambiguous way. The pattern for using this is to 1) Import + * Helper class for importing {@link Schema} objects in an unambiguous way. The pattern for using this is to 1) Import * all available search definitions, using the importXXX() methods, 2) provide the available rank types and rank * expressions, using the setRankXXX() methods, 3) invoke the {@link #build()} method, and 4) retrieve the built * search objects using the {@link #getSearch(String)} method. @@ -56,7 +56,7 @@ public class SearchBuilder { /** True to build the document aspect only, skipping instantiation of rank profiles */ private final boolean documentsOnly; - private List<Search> searchList = new LinkedList<>(); + private List<Schema> schemaList = new LinkedList<>(); private boolean isBuilt = false; /** For testing only */ @@ -171,7 +171,7 @@ public class SearchBuilder { SimpleCharStream stream = new SimpleCharStream(str); try { return importRawSearch(new SDParser(stream, fileRegistry, deployLogger, properties, application, rankProfileRegistry, documentsOnly) - .search(docTypeMgr, searchDefDir)); + .schema(docTypeMgr, searchDefDir)); } catch (TokenMgrException e) { throw new ParseException("Unknown symbol: " + e.getMessage()); } catch (ParseException pe) { @@ -181,19 +181,19 @@ public class SearchBuilder { /** * Registers the given search object to the internal list of objects to be processed during {@link #build()}. A - * {@link Search} object is considered to be "raw" if it has not already been processed. This is the case for most + * {@link Schema} object is considered to be "raw" if it has not already been processed. This is the case for most * programmatically constructed search objects used in unit tests. * * @param schema the object to import. * @return the name of the imported object. * @throws IllegalArgumentException if the given search object has already been processed. */ - public String importRawSearch(Search schema) { + public String importRawSearch(Schema schema) { if (schema.getName() == null) throw new IllegalArgumentException("Schema has no name"); String rawName = schema.getName(); application.add(schema); - searchList.add(schema); + schemaList.add(schema); return rawName; } @@ -221,12 +221,12 @@ public class SearchBuilder { if (validate) application.validate(deployLogger); - List<Search> built = new ArrayList<>(); + List<Schema> built = new ArrayList<>(); List<SDDocumentType> sdocs = new ArrayList<>(); sdocs.add(SDDocumentType.VESPA_DOCUMENT); - for (Search search : searchList) { - if (search.hasDocument()) { - sdocs.add(search.getDocument()); + for (Schema schema : schemaList) { + if (schema.hasDocument()) { + sdocs.add(schema.getDocument()); } } @@ -237,46 +237,46 @@ public class SearchBuilder { new FieldOperationApplier().process(sdoc); } - var resolver = new DocumentReferenceResolver(searchList); + var resolver = new DocumentReferenceResolver(schemaList); sdocs.forEach(resolver::resolveReferences); sdocs.forEach(resolver::resolveInheritedReferences); - var importedFieldsEnumerator = new ImportedFieldsEnumerator(searchList); + var importedFieldsEnumerator = new ImportedFieldsEnumerator(schemaList); sdocs.forEach(importedFieldsEnumerator::enumerateImportedFields); if (validate) new DocumentGraphValidator().validateDocumentGraph(sdocs); var builder = new DocumentModelBuilder(model); - for (Search search : new SearchOrderer().order(searchList)) { - new FieldOperationApplierForSearch().process(search); // TODO: Why is this not in the regular list? - process(search, new QueryProfiles(queryProfileRegistry, deployLogger), validate); - built.add(search); + for (Schema schema : new SearchOrderer().order(schemaList)) { + new FieldOperationApplierForSearch().process(schema); // TODO: Why is this not in the regular list? + process(schema, new QueryProfiles(queryProfileRegistry, deployLogger), validate); + built.add(schema); } - builder.addToModel(searchList); + builder.addToModel(schemaList); if ( validate && ! builder.valid() ) throw new IllegalArgumentException("Impossible to build a correct model"); - searchList = built; + schemaList = built; isBuilt = true; } /** - * Processes and returns the given {@link Search} object. This method has been factored out of the {@link + * Processes and returns the given {@link Schema} object. This method has been factored out of the {@link * #build()} method so that subclasses can choose not to build anything. */ - private void process(Search search, QueryProfiles queryProfiles, boolean validate) { - new Processing().process(search, deployLogger, rankProfileRegistry, queryProfiles, validate, documentsOnly); + private void process(Schema schema, QueryProfiles queryProfiles, boolean validate) { + new Processing().process(schema, deployLogger, rankProfileRegistry, queryProfiles, validate, documentsOnly); } /** - * Convenience method to call {@link #getSearch(String)} when there is only a single {@link Search} object + * Convenience method to call {@link #getSearch(String)} when there is only a single {@link Schema} object * built. This method will never return null. * * @return the built object * @throws IllegalStateException if there is not exactly one search. */ - public Search getSearch() { + public Schema getSearch() { if ( ! isBuilt) throw new IllegalStateException("Searches not built."); if (application.schemas().size() != 1) throw new IllegalStateException("This call only works if we have 1 schema. Schemas: " + @@ -290,7 +290,7 @@ public class SearchBuilder { } /** - * Returns the built {@link Search} object that has the given name. If the name is unknown, this method will simply + * Returns the built {@link Schema} object that has the given name. If the name is unknown, this method will simply * return null. * * @param name the name of the search definition to return, @@ -298,23 +298,23 @@ public class SearchBuilder { * @return the built object, or null if none with this name * @throws IllegalStateException if {@link #build()} has not been called. */ - public Search getSearch(String name) { + public Schema getSearch(String name) { if ( ! isBuilt) throw new IllegalStateException("Searches not built."); if (name == null) return getSearch(); return application.schemas().get(name); } /** - * Convenience method to return a list of all built {@link Search} objects. + * Convenience method to return a list of all built {@link Schema} objects. * * @return the list of built searches */ - public List<Search> getSearchList() { - return new ArrayList<>(searchList); + public List<Schema> getSearchList() { + return new ArrayList<>(schemaList); } /** - * Convenience factory method to import and build a {@link Search} object from a string. + * Convenience factory method to import and build a {@link Schema} object from a string. * * @param sd The string to build from. * @return The built {@link SearchBuilder} object. @@ -340,7 +340,7 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a file. Only for testing. + * Convenience factory method to import and build a {@link Schema} object from a file. Only for testing. * * @param fileName the file to build from * @return the built {@link SearchBuilder} object @@ -367,7 +367,7 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a file. + * Convenience factory method to import and build a {@link Schema} object from a file. * * @param fileName the file to build from. * @param deployLogger logger for deploy messages. @@ -456,27 +456,27 @@ public class SearchBuilder { // TODO: The build methods below just call the create methods above - remove /** - * Convenience factory method to import and build a {@link Search} object from a file. Only for testing. + * Convenience factory method to import and build a {@link Schema} object from a file. Only for testing. * * @param fileName The file to build from. - * @return The built {@link Search} object. + * @return The built {@link Schema} object. * @throws IOException Thrown if there was a problem reading the file. * @throws ParseException Thrown if there was a problem parsing the file content. */ - public static Search buildFromFile(String fileName) throws IOException, ParseException { + public static Schema buildFromFile(String fileName) throws IOException, ParseException { return buildFromFile(fileName, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfileRegistry()); } /** - * Convenience factory method to import and build a {@link Search} object from a file. + * Convenience factory method to import and build a {@link Schema} object from a file. * * @param fileName The file to build from. * @param rankProfileRegistry Registry for rank profiles. - * @return The built {@link Search} object. + * @return The built {@link Schema} object. * @throws IOException Thrown if there was a problem reading the file. * @throws ParseException Thrown if there was a problem parsing the file content. */ - public static Search buildFromFile(String fileName, + public static Schema buildFromFile(String fileName, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { @@ -484,16 +484,16 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a file. + * Convenience factory method to import and build a {@link Schema} object from a file. * * @param fileName The file to build from. * @param deployLogger Logger for deploy messages. * @param rankProfileRegistry Registry for rank profiles. - * @return The built {@link Search} object. + * @return The built {@link Schema} object. * @throws IOException Thrown if there was a problem reading the file. * @throws ParseException Thrown if there was a problem parsing the file content. */ - public static Search buildFromFile(String fileName, + public static Schema buildFromFile(String fileName, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) @@ -502,32 +502,32 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a raw object. + * Convenience factory method to import and build a {@link Schema} object from a raw object. * - * @param rawSearch the raw object to build from. + * @param rawSchema the raw object to build from. * @return the built {@link SearchBuilder} object. - * @see #importRawSearch(Search) + * @see #importRawSearch(Schema) */ - public static SearchBuilder createFromRawSearch(Search rawSearch, + public static SearchBuilder createFromRawSearch(Schema rawSchema, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { SearchBuilder builder = new SearchBuilder(rankProfileRegistry, queryProfileRegistry); - builder.importRawSearch(rawSearch); + builder.importRawSearch(rawSchema); builder.build(); return builder; } /** - * Convenience factory method to import and build a {@link Search} object from a raw object. + * Convenience factory method to import and build a {@link Schema} object from a raw object. * - * @param rawSearch The raw object to build from. - * @return The built {@link Search} object. - * @see #importRawSearch(Search) + * @param rawSchema The raw object to build from. + * @return The built {@link Schema} object. + * @see #importRawSearch(Schema) */ - public static Search buildFromRawSearch(Search rawSearch, + public static Schema buildFromRawSearch(Schema rawSchema, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { - return createFromRawSearch(rawSearch, rankProfileRegistry, queryProfileRegistry).getSearch(); + return createFromRawSearch(rawSchema, rankProfileRegistry, queryProfileRegistry).getSearch(); } public RankProfileRegistry getRankProfileRegistry() { |