test_class.declarator: searcherUnderTest
test_class.modifier: private
test_class.original_string: private IndexSearcher searcherUnderTest;
test_class.type: IndexSearcher
test_class.var_name: searcherUnderTest
test_class.declarator: indexWriterUnderTest
test_class.modifier: private
test_class.original_string: private RandomIndexWriter indexWriterUnderTest;
test_class.type: RandomIndexWriter
test_class.var_name: indexWriterUnderTest
test_class.declarator: indexReaderUnderTest
test_class.modifier: private
test_class.original_string: private IndexReader indexReaderUnderTest;
test_class.type: IndexReader
test_class.var_name: indexReaderUnderTest
test_class.declarator: dirUnderTest
test_class.modifier: private
test_class.original_string: private Directory dirUnderTest;
test_class.type: Directory
test_class.var_name: dirUnderTest
test_class.declarator: similarity
test_class.modifier: private
test_class.original_string: private Similarity similarity;
test_class.type: Similarity
test_class.var_name: similarity
test_class.declarator: analyzer
test_class.modifier: private
test_class.original_string: private StandardAnalyzer analyzer;
test_class.type: StandardAnalyzer
test_class.var_name: analyzer
test_class.declarator: similarityMap
test_class.modifier: private
test_class.original_string: private Map<String, Similarity> similarityMap;
test_class.type: Map<String, Similarity>
test_class.var_name: similarityMap
test_class.declarator: docs = new String[] {"how now brown cow",
              "brown is the color of cows",
              "brown cow",
              "banana cows are yummy"}
test_class.modifier: private final
test_class.original_string: private final String[] docs = new String[] {"how now brown cow",
              "brown is the color of cows",
              "brown cow",
              "banana cows are yummy"};
test_class.type: String[]
test_class.var_name: docs
test_class.file: extra/src/test/java/org/wikimedia/search/extra/simswitcher/SimSwitcherQueryTest.java
test_class.identifier: SimSwitcherQueryTest
test_class.superclass: extends LuceneTestCase
test_case.body: @Test
      public void testExplain() throws IOException {
          String q = "brown cow";
          for (Map.Entry<String, Similarity> entry : similarityMap.entrySet()) {
              String msg = "switch from " + similarity.getClass().getSimpleName() + " to " + entry.getKey();
              Query query = new QueryBuilder(analyzer).createBooleanQuery(entry.getKey(), q);
              Query hacked = new SimSwitcherQuery(entry.getValue(), new QueryBuilder(analyzer).createBooleanQuery("main_field", q));
              TopDocs docs = searcherUnderTest.search(query, 10);
              Weight weight = searcherUnderTest.createWeight(searcherUnderTest.rewrite(query), true, 1F);
              Weight hackedWeight = searcherUnderTest.createWeight(searcherUnderTest.rewrite(hacked), true, 1F);
              Explanation exp = searcherUnderTest.explain(query, docs.scoreDocs[0].doc);
              Explanation hackExp = searcherUnderTest.explain(hacked, docs.scoreDocs[0].doc);
              assertEquals(msg, exp.getValue(), hackExp.getValue(), Math.ulp(exp.getValue()));
          }
      }
test_case.class_method_signature: SimSwitcherQueryTest.testExplain()
test_case.full_signature: @Test public void testExplain()
test_case.identifier: testExplain
test_case.invocations: entrySet getSimpleName getClass getKey createBooleanQuery getKey getValue createBooleanQuery search createWeight rewrite createWeight rewrite explain explain assertEquals getValue getValue ulp getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testExplain()
focal_class.declarator: similarity
focal_class.modifier: private final
focal_class.original_string: private final Similarity similarity;
focal_class.type: Similarity
focal_class.var_name: similarity
focal_class.declarator: subQuery
focal_class.modifier: private final
focal_class.original_string: private final Query subQuery;
focal_class.type: Query
focal_class.var_name: subQuery
focal_class.file: extra/src/main/java/org/wikimedia/search/extra/simswitcher/SimSwitcherQuery.java
focal_class.identifier: SimSwitcherQuery
focal_class.class_method_signature: SimSwitcherQuery.SimSwitcherQuery(Similarity similarity, Query subQuery)
focal_class.full_signature: public  SimSwitcherQuery(Similarity similarity, Query subQuery)
focal_class.identifier: SimSwitcherQuery
focal_class.modifiers: public
focal_class.parameters: (Similarity similarity, Query subQuery)
focal_class.signature:  SimSwitcherQuery(Similarity similarity, Query subQuery)
focal_class.class_method_signature: SimSwitcherQuery.toString(String field)
focal_class.full_signature: @Override public String toString(String field)
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: (String field)
focal_class.return: String
focal_class.signature: String toString(String field)
focal_class.class_method_signature: SimSwitcherQuery.equals(Object obj)
focal_class.full_signature: @Override @SuppressFBWarnings(value = "BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS", justification = "handled by sameClassAs") public boolean equals(Object obj)
focal_class.identifier: equals
focal_class.modifiers: @Override @SuppressFBWarnings(value = "BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS", justification = "handled by sameClassAs") public
focal_class.parameters: (Object obj)
focal_class.return: boolean
focal_class.signature: boolean equals(Object obj)
focal_class.class_method_signature: SimSwitcherQuery.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: SimSwitcherQuery.createWeight(IndexSearcher searcher, boolean needsScores, float boost)
focal_class.full_signature: @Override public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost)
focal_class.identifier: createWeight
focal_class.modifiers: @Override public
focal_class.parameters: (IndexSearcher searcher, boolean needsScores, float boost)
focal_class.return: Weight
focal_class.signature: Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost)
focal_class.class_method_signature: SimSwitcherQuery.getSimilarity()
focal_class.full_signature: public Similarity getSimilarity()
focal_class.identifier: getSimilarity
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Similarity
focal_class.signature: Similarity getSimilarity()
focal_class.class_method_signature: SimSwitcherQuery.getSubQuery()
focal_class.full_signature: public Query getSubQuery()
focal_class.identifier: getSubQuery
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Query
focal_class.signature: Query getSubQuery()
focal_class.superclass: extends Query
focal_method.body: @Override
      public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
          if (!needsScores) {
              return searcher.createWeight(subQuery, false, boost);
          }
          final Similarity oldSim = searcher.getSimilarity(true);
          try {
              // XXX: hackish, this only works because a searcher
              // is created per SearchContext (multiple queries does not share the
              // same ContextIndexSearcher)
              // and that setSimilarity is delegated to super not the real IndexSearcher
              searcher.setSimilarity(similarity);
              return searcher.createWeight(subQuery, true, boost);
          } finally {
              searcher.setSimilarity(oldSim);
          }
      }
focal_method.class_method_signature: SimSwitcherQuery.createWeight(IndexSearcher searcher, boolean needsScores, float boost)
focal_method.full_signature: @Override public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost)
focal_method.identifier: createWeight
focal_method.invocations: createWeight getSimilarity setSimilarity createWeight setSimilarity
focal_method.modifiers: @Override public
focal_method.parameters: (IndexSearcher searcher, boolean needsScores, float boost)
focal_method.return: Weight
focal_method.signature: Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost)