diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-05-22 12:36:54 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-05-22 12:36:54 +0200 |
commit | c9bad532ed114e57594f975fdb1f697e4a288910 (patch) | |
tree | 0095e8c08eac1c333f7b4baa601d43718e2f321c /container-search/src/main/java/com/yahoo/prelude/IndexFacts.java | |
parent | 1b23e2014d0402b9d3de71c66304878057aec6e4 (diff) |
Iterate over indexes not fields
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/IndexFacts.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/IndexFacts.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java index b899f690ee1..da4ea5a891a 100644 --- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java +++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java @@ -166,8 +166,8 @@ public class IndexFacts { } private Index getIndexFromDocumentTypes(String indexName, List<String> documentTypes) { - if (indexName==null || indexName.isEmpty()) - indexName="default"; + if (indexName == null || indexName.isEmpty()) + indexName = "default"; return getIndexByCanonicNameFromDocumentTypes(indexName, documentTypes); } @@ -191,6 +191,13 @@ public class IndexFacts { return Index.nullIndex; } + private Collection<Index> getIndexes(String documentType) { + if ( ! isInitialized()) return Collections.emptyList(); + SearchDefinition sd = searchDefinitions.get(documentType); + if (sd == null) return Collections.emptyList(); + return sd.indices().values(); + } + /** Calls resolveDocumentTypes(query.getModel().getSources(), query.getModel().getRestrict()) */ private Set<String> resolveDocumentTypes(Query query) { // Assumption: Search definition name equals document name. @@ -421,6 +428,11 @@ public class IndexFacts { return IndexFacts.this.getIndexFromDocumentTypes(indexName, Collections.singletonList(documentType)); } + /** Returnbs all the indexes of a given search definition */ + public Collection<Index> getIndexes(String documentType) { + return IndexFacts.this.getIndexes(documentType); + } + /** * Returns the canonical form of the index name (Which may be the same as * the input). |