Last active
August 29, 2015 14:01
-
-
Save tjrobinson/6433524ab71ee8013d2f to your computer and use it in GitHub Desktop.
Upgrade from Lucene.NET 3 to Lucene.NET 4.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Assert.AreEqual(2, ((BooleanQuery)query.Clauses[0].Query).Clauses.Count); | |
+Assert.AreEqual(2, ((BooleanQuery)query.Clauses[0].Query).Clauses.Length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- private List<Func<T, IFieldable>> dataCtors = new List<Func<T, IFieldable>>(); | |
+ private List<Func<T, IIndexableField>> dataCtors = new List<Func<T, IIndexableField>>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- public static NumericField SetDate(this NumericField field, DateTime date) | |
+ public static IntField SetDate(this IntField field, DateTime date) | |
{ | |
- return field.SetIntValue(date.AsID()); | |
+ field.SetIntValue(date.AsID()); | |
+ return field; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- /// <summary> Return the offsetGap from the analyzer assigned to field </summary> | |
- public override int GetOffsetGap(IFieldable field) | |
+ public override int GetOffsetGap(string fieldName) | |
{ | |
- var analyzer = map.GetAnalyzer(field.Name); | |
+ var analyzer = map.GetAnalyzer(fieldName); | |
if (analyzer == null) | |
analyzer = defaultAnalyzer; | |
- return analyzer.GetOffsetGap(field); | |
+ return analyzer.GetOffsetGap(fieldName); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StandardNoStopWordsAnalyser : StandardAnalyzer | |
{ | |
public StandardNoStopWordsAnalyser() : base(Version.LUCENE_29, new HashSet<string>()) { } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Equivalent of StandardNoStopWordsAnalyser | |
new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_43, new CharArraySet(Lucene.Net.Util.Version.LUCENE_43, 0, ignoreCase: false)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-this.termAtt = AddAttribute<TermAttribute>(); | |
+this.termAtt = AddAttribute<CharTermAttribute>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-termAtt.SetTermBuffer(termAtt.Term.Trim()); | |
+termAtt.Clear(); | |
+termAtt.Append(termAtt.ToString().Trim()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Lucene.Net.Analysis.Standard; | |
using Lucene.Net.Analysis.Util; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-var luceneParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "text", new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)); | |
+var luceneParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_43, "text", new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_43)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment