mirror of https://github.com/apache/lucene.git
LUCENE-6817: ComplexPhraseQueryParser.ComplexPhraseQuery does not display slop in toString().
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1707043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
393065d27b
commit
fce60c94bb
|
@ -127,6 +127,9 @@ Optimizations
|
|||
|
||||
Bug Fixes
|
||||
|
||||
* LUCENE-6817: ComplexPhraseQueryParser.ComplexPhraseQuery does not display
|
||||
slop in toString(). (Ahmet Arslan via Dawid Weiss)
|
||||
|
||||
* LUCENE-6730: Hyper-parameter c is ignored in term frequency NormalizationH1.
|
||||
(Ahmet Arslan via Robert Muir)
|
||||
|
||||
|
|
|
@ -399,7 +399,10 @@ public class ComplexPhraseQueryParser extends QueryParser {
|
|||
|
||||
@Override
|
||||
public String toString(String field) {
|
||||
return "\"" + phrasedQueryStringContents + "\"";
|
||||
if (slopFactor == 0)
|
||||
return "\"" + phrasedQueryStringContents + "\"";
|
||||
else
|
||||
return "\"" + phrasedQueryStringContents + "\"" + "~" + slopFactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -139,6 +139,19 @@ public class TestComplexPhraseQuery extends LuceneTestCase {
|
|||
checkMatches("name:\"john smith\"~2 AND role:designer AND id:3", "3");
|
||||
}
|
||||
|
||||
public void testToStringContainsSlop() throws Exception {
|
||||
ComplexPhraseQueryParser qp = new ComplexPhraseQueryParser(defaultFieldName, analyzer);
|
||||
int slop = random().nextInt(31) + 1;
|
||||
|
||||
String qString = "name:\"j* smyth~\"~" + slop;
|
||||
Query query = qp.parse(qString);
|
||||
assertTrue("Slop is not shown in toString()", query.toString().endsWith("~" + slop));
|
||||
|
||||
String string = "\"j* smyth~\"";
|
||||
Query q = qp.parse(string);
|
||||
assertEquals("Don't show implicit slop of zero", q.toString(), string);
|
||||
}
|
||||
|
||||
public void testHashcodeEquals() throws Exception {
|
||||
ComplexPhraseQueryParser qp = new ComplexPhraseQueryParser(defaultFieldName, analyzer);
|
||||
qp.setInOrder(true);
|
||||
|
|
Loading…
Reference in New Issue