diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-06-08 11:11:19 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-06-08 11:11:19 +0200 |
commit | 739833c51230d2bdb7699906b7acaa6a8bb76044 (patch) | |
tree | d1f3a937be23676a53f16066ab3ec9e0f67d42f0 /container-search/src/main/java/com | |
parent | 6906d1d0da11d0ad46aefa016f1ba29dbf51ad22 (diff) |
Nonfunctional changes
Diffstat (limited to 'container-search/src/main/java/com')
6 files changed, 52 insertions, 30 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 3f931c92489..a4fe92b5be8 100644 --- a/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java +++ b/container-search/src/main/java/com/yahoo/prelude/IndexFacts.java @@ -1,9 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude; - import com.google.common.collect.ImmutableList; -import com.yahoo.language.process.StemMode; import com.yahoo.search.Query; import java.util.*; @@ -46,11 +44,16 @@ public class IndexFacts { /** * The name of the default search definition, which is the union of all * known document types. + * + * @deprecated do not use */ + // TODO: Make this package private in Vespa 7 + @Deprecated public static final String unionName = "unionOfAllKnown"; /** A search definition which contains the union of all settings. */ - private SearchDefinition unionSearchDefinition=new SearchDefinition(unionName); + @SuppressWarnings("deprecation") + private SearchDefinition unionSearchDefinition = new SearchDefinition(unionName); private boolean frozen; @@ -111,6 +114,11 @@ public class IndexFacts { clusterByDocument = invert(clusters); } + /** + * @deprecated set indexes at creation time instead + */ + // TODO: Remove on Vespa 7 + @Deprecated public void setSearchDefinitions(Map<String, SearchDefinition> searchDefinitions, SearchDefinition unionSearchDefinition) { ensureNotFrozen(); @@ -123,7 +131,7 @@ public class IndexFacts { } private boolean isIndexFromDocumentTypes(String indexName, List<String> documentTypes) { - if (!isInitialized()) return true; + if ( ! isInitialized()) return true; if (documentTypes.isEmpty()) { return unionSearchDefinition.getIndex(indexName) != null; @@ -300,7 +308,10 @@ public class IndexFacts { * * @param sdName name of search definition containing index, if null, modify default set * @param indexName name of index, actual or otherwise + * @deprecated set indexes at creation time instead */ + // TODO: Remove on Vespa 7 + @Deprecated public void addIndex(String sdName, String indexName) { ensureNotFrozen(); @@ -320,7 +331,10 @@ public class IndexFacts { /** * Adds an index to the specified index, and the default index settings, * overriding any current settings for this index + * @deprecated set indexes at creation time instead */ + // TODO: Remove on Vespa 7 + @Deprecated public void addIndex(String sdName, Index index) { ensureNotFrozen(); diff --git a/container-search/src/main/java/com/yahoo/prelude/IndexModel.java b/container-search/src/main/java/com/yahoo/prelude/IndexModel.java index a4e08accd48..e0a4fc3561c 100644 --- a/container-search/src/main/java/com/yahoo/prelude/IndexModel.java +++ b/container-search/src/main/java/com/yahoo/prelude/IndexModel.java @@ -15,9 +15,10 @@ import com.yahoo.container.QrSearchersConfig; /** * Parameter class used for construction IndexFacts. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ public final class IndexModel { + private static final Logger log = Logger.getLogger(IndexModel.class.getName()); // Copied from MasterClustersInfoUpdater. It's a temporary workaround for IndexFacts. @@ -72,6 +73,7 @@ public final class IndexModel { } } + @SuppressWarnings("deprecation") private void setDefinitions(IndexInfoConfig c) { searchDefinitions = new HashMap<>(); unionSearchDefinition = new SearchDefinition(IndexFacts.unionName); diff --git a/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java b/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java index 0cec7cfc19d..a9fb3e54826 100644 --- a/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java +++ b/container-search/src/main/java/com/yahoo/prelude/SearchDefinition.java @@ -12,7 +12,7 @@ import static com.yahoo.text.Lowercase.toLowerCase; * An object for storing information about search definitions in the centralized * directory services. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ // TODO: Make freezable! public class SearchDefinition { diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java index c7e3412facc..9fbaf0d83c9 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java @@ -67,22 +67,17 @@ public abstract class AbstractParser implements CustomParser { * @param indexName the index name which should decide the submodes, or null to do nothing. * @param session the session used to look up information about this index */ - @SuppressWarnings({"deprecation"}) // To avoid this we need to pass an IndexFacts.session down instead - easily done but not without breaking API's - public void setFromIndex(final String indexName, IndexFacts.Session session) { - if (indexName == null) { - return; - } + public void setFromIndex(String indexName, IndexFacts.Session session) { + if (indexName == null) return; reset(); + Index current = session.getIndex(indexName); - final Index current = session.getIndex(indexName); - - if (current.isUriIndex()) { + if (current.isUriIndex()) url = true; - } else if (current.isHostIndex()) { + else if (current.isHostIndex()) site = true; - } } /** Sets default values for all submodes */ diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java index 12a904a29e2..7c6d1285454 100644 --- a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhraseMatcher.java @@ -12,13 +12,13 @@ import java.util.NoSuchElementException; import static com.yahoo.language.LinguisticsCase.toLowerCase; /** - * <p>Detects query phrases using an automaton. This class is thread safe.</p> + * Detects query phrases using an automaton. This class is thread safe. * - * @author bratseth + * @author bratseth */ public class PhraseMatcher { - private FSA phraseFSA; + private FSA phraseFSA = null; private boolean matchPhraseItems=false; @@ -31,7 +31,7 @@ public class PhraseMatcher { private boolean matchAll =false; /** For null subclass only */ - PhraseMatcher() { + private PhraseMatcher() { } /** @@ -69,6 +69,8 @@ public class PhraseMatcher { phraseFSA=phraseAutomatonFSA; } + public boolean isEmpty() { return phraseFSA == null; } + /** * Set whether to match words contained in phrase items as well. * Default is false - don't match words contained in phrase items @@ -138,10 +140,10 @@ public class PhraseMatcher { } /** Find matches within a composite */ - private void recursivelyMatchPhrases(Item item,MatchedPhrases phrases) { - if (item==null) return; + private void recursivelyMatchPhrases(Item item, MatchedPhrases phrases) { + if (item == null) return; if ( ! (item instanceof CompositeItem) ) return; - if ( !matchPhraseItems && item instanceof PhraseItem ) return; + if ( ! matchPhraseItems && item instanceof PhraseItem ) return; CompositeItem owner=(CompositeItem)item; int i=0; @@ -547,12 +549,16 @@ public class PhraseMatcher { /** Returns a phrase matcher which (quickly) never matches anything */ public static PhraseMatcher getNullMatcher() { + return new PhraseMatcher() { - public List<Phrase> matchPhrases(Item item) { + @Override + public List<Phrase> matchPhrases(Item item) { return null; } + }; + } } diff --git a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java index 78c046efd10..f5e229fe6a2 100644 --- a/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/querytransform/PhrasingSearcher.java @@ -7,6 +7,8 @@ import com.yahoo.component.chain.dependencies.After; import com.yahoo.component.chain.dependencies.Before; import com.yahoo.component.chain.dependencies.Provides; import com.yahoo.container.QrSearchersConfig; +import com.yahoo.search.Query; +import com.yahoo.search.Result; import com.yahoo.search.Searcher; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.searchchain.Execution; @@ -16,11 +18,11 @@ import com.yahoo.search.searchchain.PhaseNames; import java.util.List; /** - * <p>Detects query phrases. When a phrase is detected in the query, - * the query is mutated to reflect this fact.</p> + * Detects query phrases. When a phrase is detected in the query, + * the query is mutated to reflect this fact. * - * @author bratseth - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author bratseth + * @author Einar M R Rosenvinge */ @After(PhaseNames.RAW_QUERY) @Before(PhaseNames.TRANSFORMED_QUERY) @@ -54,9 +56,11 @@ public class PhrasingSearcher extends Searcher { } @Override - public com.yahoo.search.Result search(com.yahoo.search.Query query, Execution execution) { + public Result search(Query query, Execution execution) { + if (phraseMatcher.isEmpty()) return execution.search(query); + List<PhraseMatcher.Phrase> replacePhrases = phraseMatcher.matchPhrases(query.getModel().getQueryTree().getRoot()); - if (replacePhrases != null && !query.properties().getBoolean(suggestonly, false)) { + if (replacePhrases != null && ! query.properties().getBoolean(suggestonly, false)) { replace(replacePhrases); query.trace("Replacing phrases", true, 2); } @@ -73,4 +77,5 @@ public class PhrasingSearcher extends Searcher { phrase.replace(); } } + } |