org.apache.solr.common.params.DisMaxParams Java Examples

The following examples show how to use org.apache.solr.common.params.DisMaxParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InfoLoggingTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatTheLogPropertyIsReturned() {

    String q = "a x";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2 f3",
            QuerqyDismaxParams.INFO_LOGGING, "on",
            "defType", "querqy"
    );

    assertQ("Log property is missing",
            req,
            "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" +
                    "str[text() = 'log msg 1 of input a']",
            "count(//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" +
                    "str) = 1"
    );

    req.close();
}
 
Example #2
Source File: CommonRulesDeleteLastTermTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatMatchAllQueryIsAppliedIfQueryContainsBoostUpQueryAndHasNoTerm() {
    String q = "d";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            "debugQuery", "on",
            "defType", "querqy");

    assertQ("",
            req,
            "//result[@name='response' and @numFound='4']"
    );
    req.close();

}
 
Example #3
Source File: DefaultQuerqyDismaxQParserWithCommonRulesTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrefixWithSynoynm() {
    String q = "Px";

    SolrQueryRequest req = req("q", q,
          DisMaxParams.QF, "f1 f2",
          DisMaxParams.MM, "2",
          QueryParsing.OP, "AND",
          "defType", "querqy",
          "debugQuery", "on"
          );
    
    assertQ("Synonym for prefix fails",
            req,
            "//result[@name='response' and @numFound='1']"

      );

    

    req.close();
}
 
Example #4
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatAnalysisIsRunForPf3() {

    String q = "K L M";
    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            DisMaxParams.MM, "3",
            QueryParsing.OP, "OR",
            "defType", "querqy",
            "debugQuery", "true",
            DisMaxParams.PF3, "f1_lc f2_lc");


    assertQ("Analysis not applied for pf",
            req,
            // Query terms should be lower-cased in analysis for pf fields
            "//str[@name='parsedquery'][contains(.,'DisjunctionMaxQuery((f1_lc:\"k l m\" | f2_lc:\"k l m\"))')]",
            // but not for query fields
            "//str[@name='parsedquery'][contains(.,'(f1:K f1:L f1:M)')]");

    req.close();

}
 
Example #5
Source File: CommonRulesConfigTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testIgnoreCaseIsTrueByDefault() throws Exception {

    String q = "M";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            "defType", "querqy4",
            "debugQuery", "true"
    );

    assertQ("Default value for ignoreCase fails",
            req,
            "//str[@name='parsedquery'][contains(.,'f1:d')]"
    );

    req.close();
}
 
Example #6
Source File: ReplaceRewriterFactoryTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaults() {
    String q = "a b d";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            "defType", "querqy_defaults",
            "debugQuery", "on"
    );

    assertQ("Replace rules",
            req,
            "//str[@name='parsedquery_toString'][text() = 'f1:e f1:f f1:g']"
    );

    req.close();
}
 
Example #7
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatPf3IsApplied() throws Exception {

   String q = "a b c d";
   SolrQueryRequest req = req("q", q,
         DisMaxParams.QF, "f1 f2",
         DisMaxParams.MM, "3",
         QueryParsing.OP, "OR",
         DisMaxParams.PF3, "f2^2.5 f3^1.5"
         );
   verifyQueryString(req, q,
         "(f2:\"a b c\" f2:\"b c d\")^2.5",
         "(f3:\"a b c\" f3:\"b c d\")^1.5"

   );

}
 
Example #8
Source File: NumberUnitRewriterTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnlimitedRange() {
    String q = "55unitUnlimited";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            "fl", "id,score",
            DisMaxParams.MM, "100%",
            "uq.similarityScore", "off",
            "defType", "querqy_standard");
            

    assertQ("", req,
            "//result[@name='response' and @numFound='3']",
            "//str[@name='id'][contains(.,'5')]",
            "//str[@name='id'][contains(.,'6')]",
            "//str[@name='id'][contains(.,'20')]"

    );
    req.close();
}
 
Example #9
Source File: DefaultQuerqyDismaxQParserWithCommonRulesTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatRuleMatchingIsCaseInsensitive() {
    String q = "T1 T2";

    SolrQueryRequest req = req("q", q,
          DisMaxParams.QF, "f1 f2 f3",
          DisMaxParams.MM, "1",
          QueryParsing.OP, "OR",
          "defType", "querqy",
          "debugQuery", "on"
          );

    assertQ("Rule matching seems to be case sensitive",
          req,
          "//str[@name='parsedquery'][not(contains(.,'t2'))]",
          "//str[@name='parsedquery'][not(contains(.,'T2'))]"
    );

    req.close();
}
 
Example #10
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatPF23FWorksWithSynonymRewriting() {

   SolrQueryRequest req = req("q", "a b c d",
         DisMaxParams.QF, "f1 f2^0.9",
         DisMaxParams.PF2, "f1~2^2.1",
         DisMaxParams.PF3, "f2~3^3.9",
         "defType", "querqy",
         "debugQuery", "true");

   assertQ("ps2/3 with synonyms not working",
         req,
         "//str[@name='parsedquery'][contains(.,'(f1:\"a b\"~2 f1:\"b c\"~2 f1:\"c d\"~2)^2.1')]",
         "//str[@name='parsedquery'][contains(.,'(f2:\"a b c\"~3 f2:\"b c d\"~3)^3.9')]");

   req.close();

}
 
Example #11
Source File: DefaultQuerqyDismaxQParserWithCommonRulesTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatPurelyNegativeRawQueryFilterIsApplied() {
    String q = "qnegraw";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2 f3",
            "defType", "querqy",
            "echoParams", "all",
            "debugQuery", "on"
    );

    assertQ("Purely negative filter fails for raw query",
            req,
            "//result[@name='response' and @numFound='1']/doc[1]/str[@name='id'][text()='11']"
    );



    req.close();
}
 
Example #12
Source File: DefaultQuerqyDismaxQParserWithCommonRulesGZIPTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testSolrFilterQuery() {

    String q = "a k";

    SolrQueryRequest req = req("q", q,
          DisMaxParams.QF, "f1 f2 f3",
          DisMaxParams.MM, "1",
          QueryParsing.OP, "OR",
          "defType", "querqy"
          );

    assertQ("Solr filter query fails",
          req,
          "//result[@name='response' and @numFound='1']"

    );

    req.close();
}
 
Example #13
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatBoostUpInPurelyNegativeSingleTokenQueryIsApplied() {
    SolrQueryRequest req = req("q", "xx uu",
            DisMaxParams.QF, "f1",
            DisMaxParams.MM, "1",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("UP on negative single query not working",
            req,
            "//result[@name='response' and @numFound='2']",
            "//result/doc[1]/str[@name='id'][text()='11']"
    );
    req.close();

}
 
Example #14
Source File: NeedsScoresTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testBoostIsAddedByDefault() {
    String q = "qup";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2",
            QueryParsing.OP, "OR",
            "defType", "querqy",
            "debugQuery", "true"
    );

    assertQ("Boost not added by default",
            req,
            "//result[@name='response'][@numFound='2']",
            // the parsed query must contain the boost terms:
            "//str[@name='parsedquery'][contains(.,'f1:u100')]",
            "//str[@name='parsedquery'][contains(.,'f2:u100')]",
            "//str[@name='parsedquery'][not(contains(.,'ConstantScore'))]");
    req.close();
}
 
Example #15
Source File: NeedsScoresTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryIsConstantScoreIfScoresAreNotNeeded() {
    String q = "qup";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2",
            QueryParsing.OP, "OR",
            NEEDS_SCORES, "false",
            "defType", "querqy",
            "debugQuery", "true"
    );

    assertQ("Not a ConstantScoreQuery",
            req,
            "//result[@name='response'][@numFound='2']",
            "//str[@name='parsedquery'][contains(.,'ConstantScore')]");
    req.close();
}
 
Example #16
Source File: CriteriaSelectionDefaultsTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testJsonFilterEquality() {
    SolrQueryRequest req = req("q", "input5 input6",
            DisMaxParams.QF, "f1",
            DisMaxParams.MM, "1",
            getFilterParamName(REWRITER_ID_3), "$[?(@.tenant)].tenant[?(@.enabled == true)]",
            "defType", "querqy",
            "debugQuery", "true"
    );

    assertQ("Json eq filter criterion doesn't work",
            req,
            "//result[@name='response' and @numFound='2']",
            "//result/doc/str[@name='id'][text()='1']",
            "//result/doc/str[@name='id'][text()='2']"
    );

    req.close();
}
 
Example #17
Source File: WordBreakCompoundRewriterTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatLowerCaseFalseConfigIsApplied() {
    String q = "Herrenjacke";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2 f3",
            DisMaxParams.MM, "100%",
            "defType", "querqyNoCollationNoLowerCase",
            "debugQuery", "on"
    );

    assertQ("Misssing decompound",
            req,
            "//result[@name='response' and @numFound='0']"
    );


    req.close();
}
 
Example #18
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatHighlightingIsApplied() {
    SolrQueryRequest req = req("q", "a",
            DisMaxParams.QF, "f1",
            HighlightParams.HIGHLIGHT, "true",
            HighlightParams.FIELDS, "f1",
            HighlightParams.SIMPLE_PRE, "PRE",
            HighlightParams.SIMPLE_POST, "POST",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("Highlighting not working",
            req,
            "//lst[@name='highlighting']//arr[@name='f1']/str[text()='PREaPOST']"
    );
    req.close();

}
 
Example #19
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatHighlightingIsNotAppliedToBoostQuery() {
    SolrQueryRequest req = req("q", "o",
            DisMaxParams.QF, "f1",
            HighlightParams.HIGHLIGHT, "true",
            HighlightParams.FIELDS, "f1",
            HighlightParams.SIMPLE_PRE, "PRE",
            HighlightParams.SIMPLE_POST, "POST",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("UP token is highlighted",
            req,
            "//lst[@name='highlighting']//arr[@name='f1']/str[not(contains(.,'PREuPOST'))]"
    );
    req.close();

}
 
Example #20
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatHighlightingIsAppliedToSynonyms() {
    SolrQueryRequest req = req("q", "o",
            DisMaxParams.QF, "f1",
            HighlightParams.HIGHLIGHT, "true",
            HighlightParams.FIELDS, "f1",
            HighlightParams.SIMPLE_PRE, "PRE",
            HighlightParams.SIMPLE_POST, "POST",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("UP token is highlighted",
            req,
            "//lst[@name='highlighting']//arr[@name='f1']/str[contains(.,'PREsPOST')]"
    );
    req.close();

}
 
Example #21
Source File: CriteriaSelectionTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testJsonList() {
    SolrQueryRequest req = req("q", "input5 input6",
            DisMaxParams.QF, "f1",
            DisMaxParams.MM, "1",
            getStrategyParamName(REWRITER_ID_3), "criteria",
            getFilterParamName(REWRITER_ID_3), "$[?('a' IN @.tt)]",
            "defType", "querqy",
            "debugQuery", "true"
    );

    assertQ("Json eq filter criterion doesn't work",
            req,
            "//result[@name='response' and @numFound='1']"
    );

    req.close();
}
 
Example #22
Source File: DocumentFrequencyCorrectionTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testDfGetsCorrectedForBoostUp() throws Exception {

   String q = "a c";

   SolrQueryRequest req = req("q", q,
         DisMaxParams.QF, "f1 f2",
         QueryParsing.OP, "OR",
         DisMaxParams.TIE, "0.1",
         "defType", "querqy",
         "debugQuery", "true"
         );
   assertQ("wrong df",
         req,
         "//str[@name='2'][contains(.,'7 = n, number of documents containing term')]",
         "//str[@name='2'][not(contains(.,'1 = n, number of documents containing term'))]",
         "//str[@name='7'][contains(.,'10 = n, number of documents containing term')]",
         "//str[@name='7'][not(contains(.,'4 = n, number of documents containing term'))]");

   req.close();
}
 
Example #23
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatBqIsApplied() {

    SolrQueryRequest req = req("q", "aaa",
            DisMaxParams.QF, "f1",
            DisMaxParams.BQ, "f2:w87",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("bq not applied",
            req,
            "//str[@name='parsedquery'][contains(.,'f2:w87')]",
            "//str[@name='parsedquery'][not(contains(.,'BoostedQuery'))]",
            "//doc[1]/str[@name='id'][text()='8']"

    );
    req.close();

}
 
Example #24
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatBqIsAppliedToMatchAllDocsQuery() {

    SolrQueryRequest req = req("q", "*:*",
            DisMaxParams.QF, "f1",
            DisMaxParams.BQ, "f2:w87",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("bq not applied to MatchAll",
            req,
            "//result[@numFound='11']",
            "//str[@name='parsedquery'][contains(.,'f2:w87')]",
            "//str[@name='parsedquery'][not(contains(.,'BoostedQuery'))]",
            "//doc[1]/str[@name='id'][text()='8']"

    );
    req.close();

}
 
Example #25
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatBqIsAppliedToMatchAllDocsQueryRegardlessOfPf() {

    SolrQueryRequest req = req("q", "*:*",
            DisMaxParams.QF, "f1",
            DisMaxParams.BQ, "f2:w87",
            DisMaxParams.PF, "f1",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("bq not applied to MatchAll",
            req,
            "//result[@numFound='11']",
            "//str[@name='parsedquery'][contains(.,'f2:w87')]",
            "//str[@name='parsedquery'][not(contains(.,'BoostedQuery'))]",
            "//doc[1]/str[@name='id'][text()='8']"

    );
    req.close();

}
 
Example #26
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatBoostParamIsApplied() {

    SolrQueryRequest req = req("q", "aaa",
            DisMaxParams.QF, "f1",
            QuerqyDismaxParams.MULT_BOOST, "{!lucene}f2:w87^100",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("bq not applied",
            req,
            "//lst[@name='explain']/str[@name='8'][contains(.,'weight(FunctionScoreQuery(f1:aaa, " +
                    "scored by boost(score((f2:w87)^100.0))))')]",
            "//doc[1]/str[@name='id'][text()='8']"

    );
    req.close();

}
 
Example #27
Source File: DefaultQuerqyDismaxQParserTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatSeveralBoostParamsAreApplied() {

    SolrQueryRequest req = req("q", "aaa",
            DisMaxParams.QF, "f1",
            QuerqyDismaxParams.MULT_BOOST, "{!lucene}f2:w87^100",
            QuerqyDismaxParams.MULT_BOOST, "{!lucene}f2:w87^200",
            "defType", "querqy",
            "debugQuery", "true");

    assertQ("bq not applied",
            req,
            "//lst[@name='explain']/str[@name='8'][contains(.,'weight(FunctionScoreQuery(f1:aaa, " +
                    "scored by boost(product(query((f2:w87)^100.0,def=1.0),query((f2:w87)^200.0,def=1.0)))))')]",
            "//doc[1]/str[@name='id'][text()='8']"

    );
    req.close();
}
 
Example #28
Source File: UserQueryWithSimilarityOnTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatDfAndDfAreUsedForRanking() {
    String q = "a";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2 f3",
            QueryParsing.OP, "OR",
            DisMaxParams.TIE, "0.0",
            "defType", "querqy",
            "uq.similarityScore", "on",
            "debugQuery", "true"
    );
    assertQ("Ranking",
            req,
            "//doc[1]/str[@name='id'][contains(.,'3')]",
            "//doc[2]/str[@name='id'][contains(.,'4')]",
            "//lst[@name='explain']/str[@name='3'][contains(.,'idf, computed as')]"
    );

    req.close();
}
 
Example #29
Source File: NumberUnitRewriterTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilteringForSingleNumberUnitInputAndMultipleUnitConfig() {
    String q = "tv 210 cm";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            DisMaxParams.MM, "100%",
            "echoParams", "all",
            "defType", "querqy_standard");
            

    assertQ("",
            req,
            "//result[@name='response' and @numFound='2']",
            "//str[@name='id'][contains(.,'1')]",
            "//str[@name='id'][contains(.,'2')]"
    );
    req.close();
}
 
Example #30
Source File: InfoLoggingTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
public void testThatLogOutputIsTurnedOffByDefault() {

        String q = "k";

        SolrQueryRequest req = req("q", q,
                DisMaxParams.QF, "f1 f2 f3",
                "defType", "querqy"
        );

        assertQ("Logging multiple logs for same input false",
                req,
                "count(//lst[@name='querqy.infoLog']/arr) = 0"
        );

        req.close();
    }