You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2012/03/23 02:32:54 UTC
svn commit: r1304159 [3/3] - in /incubator/lucene.net/trunk:
src/core/QueryParser/ test/contrib/Analyzers/De/
test/contrib/Core/Analysis/Ext/ test/core/QueryParser/ test/core/Search/
Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/De/TestGermanStemFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/De/TestGermanStemFilter.cs?rev=1304159&r1=1304158&r2=1304159&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/De/TestGermanStemFilter.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/De/TestGermanStemFilter.cs Fri Mar 23 01:32:53 2012
@@ -20,9 +20,7 @@
*/
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.De;
Modified: incubator/lucene.net/trunk/test/contrib/Analyzers/De/data.txt
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Analyzers/De/data.txt?rev=1304159&r1=1304158&r2=1304159&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Analyzers/De/data.txt (original)
+++ incubator/lucene.net/trunk/test/contrib/Analyzers/De/data.txt Fri Mar 23 01:32:53 2012
@@ -1,5 +1,7 @@
# German special characters are replaced:
häufig;haufig
+üor;uor
+björk;bjork
# here the stemmer works okay, it maps related words to the same stem:
abschlieÃen;abschliess
Modified: incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs?rev=1304159&r1=1304158&r2=1304159&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs (original)
+++ incubator/lucene.net/trunk/test/contrib/Core/Analysis/Ext/Analysis.Ext.Test.cs Fri Mar 23 01:32:53 2012
@@ -59,9 +59,10 @@ namespace Lucene.Net.Analysis.Ext
IndexSearcher src = CreateIndex("someuser@gmail.com 1234567890 abcdefgh", analyzer);
var p = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "field", analyzer)
- {DefaultOperator = QueryParser.Operator.AND};
- var setEnable = new QueryParser.SetEnablePositionIncrementsParams(true);
- p.SetEnablePositionIncrements(setEnable);
+ {
+ DefaultOperator = QueryParser.Operator.AND,
+ EnablePositionIncrements = true
+ };
TopDocs td = null;
Modified: incubator/lucene.net/trunk/test/core/QueryParser/TestMultiAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/QueryParser/TestMultiAnalyzer.cs?rev=1304159&r1=1304158&r2=1304159&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/QueryParser/TestMultiAnalyzer.cs (original)
+++ incubator/lucene.net/trunk/test/core/QueryParser/TestMultiAnalyzer.cs Fri Mar 23 01:32:53 2012
@@ -325,7 +325,7 @@ namespace Lucene.Net.QueryParsers
return base.GetFieldQuery(f, t);
}
/// <summary>wrap super's version </summary>
- public /*protected internal*/ override Query GetFieldQuery(System.String f, System.String t)
+ protected internal override Query GetFieldQuery(System.String f, System.String t)
{
return new DumbQueryWrapper(GetSuperFieldQuery(f, t));
}
Modified: incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs?rev=1304159&r1=1304158&r2=1304159&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs (original)
+++ incubator/lucene.net/trunk/test/core/QueryParser/TestQueryParser.cs Fri Mar 23 01:32:53 2012
@@ -96,20 +96,20 @@ namespace Lucene.Net.QueryParsers
{
InitBlock(type, enclosingInstance);
}
- public /*protected internal*/ override Query GetWildcardQuery(System.String field, System.String termStr)
+ protected internal override Query GetWildcardQuery(System.String field, System.String termStr)
{
// override error checking of superclass
type[0] = 1;
return new TermQuery(new Term(field, termStr));
}
- public /*protected internal*/ override Query GetPrefixQuery(System.String field, System.String termStr)
+ protected internal override Query GetPrefixQuery(System.String field, System.String termStr)
{
// override error checking of superclass
type[0] = 2;
return new TermQuery(new Term(field, termStr));
}
- public /*protected internal*/ override Query GetFieldQuery(System.String field, System.String queryText)
+ protected internal override Query GetFieldQuery(System.String field, System.String queryText)
{
type[0] = 3;
return base.GetFieldQuery(field, queryText);
@@ -191,12 +191,12 @@ namespace Lucene.Net.QueryParsers
{
}
- public /*protected internal*/ override Query GetFuzzyQuery(System.String field, System.String termStr, float minSimilarity)
+ protected internal override Query GetFuzzyQuery(System.String field, System.String termStr, float minSimilarity)
{
throw new ParseException("Fuzzy queries not allowed");
}
- public /*protected internal*/ override Query GetWildcardQuery(System.String field, System.String termStr)
+ protected internal override Query GetWildcardQuery(System.String field, System.String termStr)
{
throw new ParseException("Wildcard queries not allowed");
}
@@ -1078,8 +1078,8 @@ namespace Lucene.Net.QueryParsers
QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a",
new StopAnalyzer(Version.LUCENE_CURRENT,
StopFilter.MakeStopSet(new[] {"the", "in", "are", "this"})));
- qp.SetEnablePositionIncrements(new QueryParser.SetEnablePositionIncrementsParams(true));
- System.String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
+ qp.EnablePositionIncrements = true;
+ string qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
// 0 2 5 7 8
int[] expectedPositions = new int[] {1, 3, 4, 6, 9};
PhraseQuery pq = (PhraseQuery) qp.Parse(qtxt);
@@ -1180,5 +1180,86 @@ namespace Lucene.Net.QueryParsers
Assert.Fail("please switch public QueryParser(QueryParserTokenManager) to be protected");
}
}
+
+ [Test]
+ public void TestVersioningOfJavaDateRangeBehavior()
+ {
+ var startDate = GetLocalizedDate(2002, 1, 1, false);
+ var endDate = GetLocalizedDate(2002, 1, 4, false);
+
+ System.Globalization.Calendar calendar = new System.Globalization.GregorianCalendar();
+ var endDateExpected = new DateTime(2002, 1, 4, 23, 59, 59, 999, calendar);
+
+ var qp = new QueryParser(Version.LUCENE_24, "field", new SimpleAnalyzer());
+
+ // Don't set any date resolution and verify if DateField is used
+ AssertDateRangeQueryEquals(qp, "default", startDate, endDate, endDateExpected, null);
+
+ // Use dates with dashes in them, which aren't parsed out as dates in Java
+ AssertDateRangeQueryEquals(qp, "default", "2002-1-1", "2002-1-4", endDateExpected, null);
+
+ qp = new QueryParser(Version.LUCENE_CURRENT, "field", new SimpleAnalyzer());
+
+ // We still want to make sure that a localized date of "M/d/YYYY" will be parsed out
+ // as a datefield as expected.
+ AssertDateRangeQueryEquals(qp, "default", startDate, endDate, endDateExpected, null);
+
+ // This should be a normal query, NOT a date query if we're emulating Java (on or above Version LUCENE_30)
+ AssertQueryEquals(qp, "field", "default:[2002-1-1 TO 2002-1-4]", "default:[2002-1-1 TO 2002-1-4]");
+ }
+
+ // LUCENENET-478: The QueryParser hadn't been updated in so long
+ // it had an issue where stopwords inside of phrase queries
+ // would be given a null query instead of skipped when EnablePositionIncrements
+ // was set to false, so a ToString() on the query would make a query of "Query With Stopwords"
+ // into "Query ? Stopwords", regardless of request behavior of position increments
+ [Test]
+ public void TestStopWordsInPhraseQuery()
+ {
+ var qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT));
+
+ var result = qp.Parse("\"Query With Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
+
+ result = qp.Parse("\"Query OR Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
+
+ result = qp.Parse("\"Query and Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
+
+ result = qp.Parse("\"Query AND Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
+
+ // Disable position increments to attempt to remove ? from PhraseQuery.ToString()
+ qp.EnablePositionIncrements = false;
+
+ result = qp.Parse("\"Query With Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query stopwords\"", result.ToString());
+
+ result = qp.Parse("\"Query OR Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query stopwords\"", result.ToString());
+
+ result = qp.Parse("\"Query and Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query stopwords\"", result.ToString());
+
+ result = qp.Parse("\"Query AND Stopwords\"");
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result is PhraseQuery);
+ Assert.AreEqual("a:\"query stopwords\"", result.ToString());
+ }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs?rev=1304159&r1=1304158&r2=1304159&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs Fri Mar 23 01:32:53 2012
@@ -396,7 +396,7 @@ namespace Lucene.Net.Search
{
StopAnalyzer analyzer = new StopAnalyzer(Util.Version.LUCENE_CURRENT);
QueryParser qp = new QueryParser(Util.Version.LUCENE_CURRENT, "field", analyzer);
- qp.SetEnablePositionIncrements(new QueryParser.SetEnablePositionIncrementsParams(true));
+ qp.EnablePositionIncrements = true;
PhraseQuery q = (PhraseQuery) qp.Parse("\"this hi this is a test is\"");
Assert.AreEqual("field:\"? hi ? ? ? test\"", q.ToString());
q.Add(new Term("field", "hello"), 1);
Modified: incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs?rev=1304159&r1=1304158&r2=1304159&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs Fri Mar 23 01:32:53 2012
@@ -243,20 +243,20 @@ namespace Lucene.Net.Search
Assert.AreEqual(0, hits.Length);
// query parser alone won't help, because stop filter swallows the increments.
- qp.SetEnablePositionIncrements(new QueryParser.SetEnablePositionIncrementsParams(true));
+ qp.EnablePositionIncrements = true;
q = (PhraseQuery) qp.Parse("\"1 stop 2\"");
hits = searcher.Search(q, null, 1000).ScoreDocs;
Assert.AreEqual(0, hits.Length);
// stop filter alone won't help, because query parser swallows the increments.
- qp.SetEnablePositionIncrements(new QueryParser.SetEnablePositionIncrementsParams(false));
+ qp.EnablePositionIncrements = false;
q = (PhraseQuery) qp.Parse("\"1 stop 2\"");
hits = searcher.Search(q, null, 1000).ScoreDocs;
Assert.AreEqual(0, hits.Length);
// when both qp qnd stopFilter propagate increments, we should find the doc.
qp = new QueryParser(Util.Version.LUCENE_CURRENT, "field", new StopWhitespaceAnalyzer(true));
- qp.SetEnablePositionIncrements(new QueryParser.SetEnablePositionIncrementsParams(true));
+ qp.EnablePositionIncrements = true;
q = (PhraseQuery) qp.Parse("\"1 stop 2\"");
hits = searcher.Search(q, null, 1000).ScoreDocs;
Assert.AreEqual(1, hits.Length);