diff --git a/src/UmbracoExamine/SearchCriteria/ExamineValue.cs b/src/UmbracoExamine/SearchCriteria/ExamineValue.cs
deleted file mode 100644
index 6a106269af..0000000000
--- a/src/UmbracoExamine/SearchCriteria/ExamineValue.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using Examine.SearchCriteria;
-
-namespace UmbracoExamine.SearchCriteria
-{
- internal class ExamineValue : IExamineValue
- {
- public ExamineValue(Examineness vagueness, string value) : this(vagueness, value, 1)
- {
- }
-
- public ExamineValue(Examineness vagueness, string value, float level)
- {
- this.Examineness = vagueness;
- this.Value = value;
- this.Level = level;
- }
-
- public Examineness Examineness
- {
- get;
- private set;
- }
-
- public string Value
- {
- get;
- private set;
- }
-
- public float Level
- {
- get;
- private set;
- }
-
- }
-}
diff --git a/src/UmbracoExamine/SearchCriteria/LuceneBooleanOperation.cs b/src/UmbracoExamine/SearchCriteria/LuceneBooleanOperation.cs
deleted file mode 100644
index 9845d9cf77..0000000000
--- a/src/UmbracoExamine/SearchCriteria/LuceneBooleanOperation.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using Examine.SearchCriteria;
-using Lucene.Net.Search;
-
-namespace UmbracoExamine.SearchCriteria
-{
- ///
- /// An implementation of the fluent API boolean operations
- ///
- public class LuceneBooleanOperation : IBooleanOperation
- {
- private LuceneSearchCriteria search;
-
- internal LuceneBooleanOperation(LuceneSearchCriteria search)
- {
- this.search = search;
- }
-
- #region IBooleanOperation Members
-
- ///
- /// Sets the next operation to be AND
- ///
- ///
- public IQuery And()
- {
- return new LuceneQuery(this.search, BooleanClause.Occur.MUST);
- }
-
- ///
- /// Sets the next operation to be OR
- ///
- ///
- public IQuery Or()
- {
- return new LuceneQuery(this.search, BooleanClause.Occur.SHOULD);
- }
-
- ///
- /// Sets the next operation to be NOT
- ///
- ///
- public IQuery Not()
- {
- return new LuceneQuery(this.search, BooleanClause.Occur.MUST_NOT);
- }
-
- ///
- /// Compiles this instance for fluent API conclusion
- ///
- ///
- public ISearchCriteria Compile()
- {
- if (!string.IsNullOrEmpty(this.search.SearchIndexType))
- {
- var query = this.search.query;
-
- this.search.query = new BooleanQuery();
- this.search.query.Add(query, BooleanClause.Occur.MUST);
-
- //this.search.query.Add(this.search.queryParser.Parse("(" + query.ToString() + ")"), BooleanClause.Occur.MUST);
-
- this.search.FieldInternal(LuceneExamineIndexer.IndexTypeFieldName, new ExamineValue(Examineness.Explicit, this.search.SearchIndexType.ToString().ToLower()), BooleanClause.Occur.MUST);
- }
-
- return this.search;
- }
-
- #endregion
- }
-}
diff --git a/src/UmbracoExamine/SearchCriteria/LuceneQuery.cs b/src/UmbracoExamine/SearchCriteria/LuceneQuery.cs
deleted file mode 100644
index 74d20f58a0..0000000000
--- a/src/UmbracoExamine/SearchCriteria/LuceneQuery.cs
+++ /dev/null
@@ -1,330 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Examine.SearchCriteria;
-using Lucene.Net.Search;
-
-namespace UmbracoExamine.SearchCriteria
-{
- public class LuceneQuery : IQuery
- {
- private LuceneSearchCriteria search;
- private BooleanClause.Occur occurance;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The search.
- /// The occurance.
- internal LuceneQuery(LuceneSearchCriteria search, BooleanClause.Occur occurance)
- {
- this.search = search;
- this.occurance = occurance;
- }
-
- ///
- /// Gets the boolean operation which this query method will be added as
- ///
- /// The boolean operation.
- public BooleanOperation BooleanOperation
- {
- get { return occurance.ToBooleanOperation(); }
- }
-
-
- #region ISearch Members
-
- ///
- /// Query on the id
- ///
- /// The id.
- /// A new with the clause appended
- public IBooleanOperation Id(int id)
- {
- return this.search.IdInternal(id, this.occurance);
- }
-
- ///
- /// Query on the NodeName
- ///
- /// Name of the node.
- /// A new with the clause appended
- public IBooleanOperation NodeName(string nodeName)
- {
- return this.search.NodeNameInternal(new ExamineValue(Examineness.Explicit, nodeName), occurance);
- }
-
- ///
- /// Query on the NodeTypeAlias
- ///
- /// The node type alias.
- /// A new with the clause appended
- public IBooleanOperation NodeTypeAlias(string nodeTypeAlias)
- {
- return this.search.NodeTypeAliasInternal(new ExamineValue(Examineness.Explicit, nodeTypeAlias), occurance);
- }
-
- ///
- /// Query on the Parent ID
- ///
- /// The id of the parent.
- /// A new with the clause appended
- public IBooleanOperation ParentId(int id)
- {
- return this.search.ParentIdInternal(id, occurance);
- }
-
- ///
- /// Query on the specified field
- ///
- /// Name of the field.
- /// The field value.
- /// A new with the clause appended
- public IBooleanOperation Field(string fieldName, string fieldValue)
- {
- return this.search.FieldInternal(fieldName, new ExamineValue(Examineness.Explicit, fieldValue), occurance);
- }
-
- ///
- /// Ranges the specified field name.
- ///
- /// Name of the field.
- /// The start.
- /// The end.
- /// A new with the clause appended
- public IBooleanOperation Range(string fieldName, DateTime start, DateTime end)
- {
- return this.Range(fieldName, start, end, true, true);
- }
-
- ///
- /// Ranges the specified field name.
- ///
- /// Name of the field.
- /// The start.
- /// The end.
- /// if set to true [include lower].
- /// if set to true [include upper].
- /// A new with the clause appended
- public IBooleanOperation Range(string fieldName, DateTime start, DateTime end, bool includeLower, bool includeUpper)
- {
- return this.search.Range(fieldName, start, end, includeLower, includeUpper);
- }
-
- ///
- /// Ranges the specified field name.
- ///
- /// Name of the field.
- /// The start.
- /// The end.
- /// A new with the clause appended
- public IBooleanOperation Range(string fieldName, int start, int end)
- {
- return this.Range(fieldName, start, end, true, true);
- }
-
- ///
- /// Ranges the specified field name.
- ///
- /// Name of the field.
- /// The start.
- /// The end.
- /// if set to true [include lower].
- /// if set to true [include upper].
- /// A new with the clause appended
- public IBooleanOperation Range(string fieldName, int start, int end, bool includeLower, bool includeUpper)
- {
- return this.search.RangeInternal(fieldName, start, end, includeLower, includeUpper, occurance);
- }
-
- ///
- /// Ranges the specified field name.
- ///
- /// Name of the field.
- /// The start.
- /// The end.
- /// A new with the clause appended
- public IBooleanOperation Range(string fieldName, string start, string end)
- {
- return this.Range(fieldName, start, end, true, true);
- }
-
- ///
- /// Ranges the specified field name.
- ///
- /// Name of the field.
- /// The start.
- /// The end.
- /// if set to true [include lower].
- /// if set to true [include upper].
- /// A new with the clause appended
- public IBooleanOperation Range(string fieldName, string start, string end, bool includeLower, bool includeUpper)
- {
- return this.search.RangeInternal(fieldName, start, end, includeLower, includeUpper, occurance);
- }
-
- ///
- /// Query on the NodeName
- ///
- /// Name of the node.
- /// A new with the clause appended
- public IBooleanOperation NodeName(IExamineValue nodeName)
- {
- return this.search.NodeNameInternal(nodeName, occurance);
- }
-
- ///
- /// Query on the NodeTypeAlias
- ///
- /// The node type alias.
- /// A new with the clause appended
- public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias)
- {
- return this.search.NodeTypeAliasInternal(nodeTypeAlias, occurance);
- }
-
- ///
- /// Query on the specified field
- ///
- /// Name of the field.
- /// The field value.
- /// A new with the clause appended
- public IBooleanOperation Field(string fieldName, IExamineValue fieldValue)
- {
- return this.search.FieldInternal(fieldName, fieldValue, occurance);
- }
-
- ///
- /// Queries multiple fields with each being an And boolean operation
- ///
- /// The fields.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedAnd(IEnumerable fields, params string[] query)
- {
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
- return this.search.GroupedAndInternal(fields.ToArray(), fieldVals.ToArray(), this.occurance);
- }
-
- ///
- /// Queries multiple fields with each being an And boolean operation
- ///
- /// The fields.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedAnd(IEnumerable fields, params IExamineValue[] query)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Queries multiple fields with each being an Or boolean operation
- ///
- /// The fields.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedOr(IEnumerable fields, params string[] query)
- {
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
- return this.search.GroupedOrInternal(fields.ToArray(), fieldVals.ToArray(), this.occurance);
- }
-
- ///
- /// Queries multiple fields with each being an Or boolean operation
- ///
- /// The fields.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedOr(IEnumerable fields, params IExamineValue[] query)
- {
- return this.search.GroupedOrInternal(fields.ToArray(), query, this.occurance);
- }
-
- ///
- /// Queries multiple fields with each being an Not boolean operation
- ///
- /// The fields.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedNot(IEnumerable fields, params string[] query)
- {
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
- return this.search.GroupedNotInternal(fields.ToArray(), fieldVals.ToArray(), this.occurance);
- }
-
- ///
- /// Queries multiple fields with each being an Not boolean operation
- ///
- /// The fields.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedNot(IEnumerable fields, params IExamineValue[] query)
- {
- return this.search.GroupedNotInternal(fields.ToArray(), query, this.occurance);
- }
-
- ///
- /// Queries on multiple fields with their inclusions customly defined
- ///
- /// The fields.
- /// The operations.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedFlexible(IEnumerable fields, IEnumerable operations, params string[] query)
- {
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
- return this.search.GroupedFlexibleInternal(fields.ToArray(), operations.ToArray(), fieldVals.ToArray(), occurance);
- }
-
- ///
- /// Queries on multiple fields with their inclusions customly defined
- ///
- /// The fields.
- /// The operations.
- /// The query.
- /// A new with the clause appended
- public IBooleanOperation GroupedFlexible(IEnumerable fields, IEnumerable operations, params IExamineValue[] query)
- {
- return this.search.GroupedFlexibleInternal(fields.ToArray(), operations.ToArray(), query, occurance);
- }
-
- ///
- /// Orders the results by the specified fields
- ///
- /// The field names.
- /// A new with the clause appended
- public IBooleanOperation OrderBy(params string[] fieldNames)
- {
- return this.search.OrderBy(fieldNames);
- }
-
- ///
- /// Orders the results by the specified fields in a descending order
- ///
- /// The field names.
- /// A new with the clause appended
- public IBooleanOperation OrderByDescending(params string[] fieldNames)
- {
- return this.search.OrderByDescending(fieldNames);
- }
-
- #endregion
-
- }
-}
diff --git a/src/UmbracoExamine/SearchCriteria/LuceneSearchCriteria.cs b/src/UmbracoExamine/SearchCriteria/LuceneSearchCriteria.cs
deleted file mode 100644
index e11c50b88f..0000000000
--- a/src/UmbracoExamine/SearchCriteria/LuceneSearchCriteria.cs
+++ /dev/null
@@ -1,559 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using Examine;
-using Examine.SearchCriteria;
-using Lucene.Net.Analysis;
-using Lucene.Net.QueryParsers;
-using Lucene.Net.Search;
-using Lucene.Net.Search.Spans;
-using Lucene.Net.Index;
-using Lucene.Net.Documents;
-
-namespace UmbracoExamine.SearchCriteria
-{
- ///
- /// This class is used to query against Lucene.Net
- ///
- public class LuceneSearchCriteria : ISearchCriteria
- {
- internal MultiFieldQueryParser queryParser;
- internal BooleanQuery query;
- internal List sortFields = new List();
- private readonly BooleanClause.Occur occurance;
- private readonly Lucene.Net.Util.Version luceneVersion = Lucene.Net.Util.Version.LUCENE_29;
-
- internal LuceneSearchCriteria(string type, Analyzer analyzer, string[] fields, bool allowLeadingWildcards, BooleanOperation occurance)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
-
- SearchIndexType = type;
- query = new BooleanQuery();
- this.BooleanOperation = occurance;
- this.queryParser = new MultiFieldQueryParser(luceneVersion, fields, analyzer);
- this.queryParser.SetAllowLeadingWildcard(allowLeadingWildcards);
- this.occurance = occurance.ToLuceneOccurance();
- }
-
- ///
- /// Gets the boolean operation which this query method will be added as
- ///
- /// The boolean operation.
- public BooleanOperation BooleanOperation
- {
- get;
- protected set;
- }
-
- ///
- /// Returns a that represents this instance.
- ///
- ///
- /// A that represents this instance.
- ///
- public override string ToString()
- {
- return string.Format("{{ SearchIndexType: {0}, LuceneQuery: {1} }}", this.SearchIndexType, this.query.ToString());
- }
-
- private static void ValidateIExamineValue(IExamineValue v)
- {
- var ev = v as ExamineValue;
- if (ev == null)
- {
- throw new ArgumentException("IExamineValue was not created from this provider. Ensure that it is created from the ISearchCriteria this provider exposes");
- }
- }
-
- #region ISearchCriteria Members
-
- public string SearchIndexType
- {
- get;
- protected set;
- }
-
- public bool IncludeHitCount
- {
- get;
- set;
- }
-
- public int TotalHits
- {
- get;
- internal protected set;
- }
-
- #endregion
-
- #region ISearch Members
-
- ///
- /// Query on the id
- ///
- /// The id.
- /// A new with the clause appended
- public IBooleanOperation Id(int id)
- {
- return IdInternal(id, occurance);
- }
-
- internal protected IBooleanOperation IdInternal(int id, BooleanClause.Occur occurance)
- {
- //use a query parser (which uses the analyzer) to build up the field query which we want
- query.Add(this.queryParser.GetFieldQuery(LuceneExamineIndexer.IndexNodeIdFieldName, id.ToString()), occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- ///
- /// Query on the NodeName
- ///
- /// Name of the node.
- /// A new with the clause appended
- public IBooleanOperation NodeName(string nodeName)
- {
- Enforcer.ArgumentNotNull(nodeName, "nodeName");
- return NodeName(new ExamineValue(Examineness.Explicit, nodeName));
- }
-
- ///
- /// Query on the NodeName
- ///
- /// Name of the node.
- /// A new with the clause appended
- public IBooleanOperation NodeName(IExamineValue nodeName)
- {
- Enforcer.ArgumentNotNull(nodeName, "nodeName");
- return this.NodeNameInternal(nodeName, occurance);
- }
-
- internal protected IBooleanOperation NodeNameInternal(IExamineValue examineValue, BooleanClause.Occur occurance)
- {
- return this.FieldInternal("nodeName", examineValue, occurance);
- }
-
- ///
- /// Query on the NodeTypeAlias
- ///
- /// The node type alias.
- /// A new with the clause appended
- public IBooleanOperation NodeTypeAlias(string nodeTypeAlias)
- {
- Enforcer.ArgumentNotNull(nodeTypeAlias, "nodeTypeAlias");
- return this.NodeTypeAlias(new ExamineValue(Examineness.Explicit, nodeTypeAlias));
- }
-
- ///
- /// Query on the NodeTypeAlias
- ///
- /// The node type alias.
- /// A new with the clause appended
- public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias)
- {
- Enforcer.ArgumentNotNull(nodeTypeAlias, "nodeTypeAlias");
- return this.NodeTypeAliasInternal(nodeTypeAlias, occurance);
- }
-
- internal protected IBooleanOperation NodeTypeAliasInternal(IExamineValue examineValue, BooleanClause.Occur occurance)
- {
- return this.FieldInternal("nodeTypeAlias", examineValue, occurance);
- }
-
- ///
- /// Query on the Parent ID
- ///
- /// The id of the parent.
- /// A new with the clause appended
- public IBooleanOperation ParentId(int id)
- {
- return this.ParentIdInternal(id, occurance);
- }
-
- internal protected IBooleanOperation ParentIdInternal(int id, BooleanClause.Occur occurance)
- {
- query.Add(this.queryParser.GetFieldQuery("parentID", id.ToString()), occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- ///
- /// Query on the specified field
- ///
- /// Name of the field.
- /// The field value.
- /// A new with the clause appended
- public IBooleanOperation Field(string fieldName, string fieldValue)
- {
- Enforcer.ArgumentNotNull(fieldName, "fieldName");
- Enforcer.ArgumentNotNull(fieldValue, "fieldValue");
- return this.FieldInternal(fieldName, new ExamineValue(Examineness.Explicit, fieldValue), occurance);
- }
-
- ///
- /// Query on the specified field
- ///
- /// Name of the field.
- /// The field value.
- /// A new with the clause appended
- public IBooleanOperation Field(string fieldName, IExamineValue fieldValue)
- {
- Enforcer.ArgumentNotNull(fieldName, "fieldName");
- Enforcer.ArgumentNotNull(fieldValue, "fieldValue");
- return this.FieldInternal(fieldName, fieldValue, occurance);
- }
-
- ///
- /// Returns the Lucene query object for a field given an IExamineValue
- ///
- ///
- ///
- /// A new with the clause appended
- internal protected Query GetFieldInternalQuery(string fieldName, IExamineValue fieldValue)
- {
- Query queryToAdd;
-
- switch (fieldValue.Examineness)
- {
- case Examineness.Fuzzy:
- queryToAdd = this.queryParser.GetFuzzyQuery(fieldName, fieldValue.Value, fieldValue.Level);
- break;
- case Examineness.SimpleWildcard:
- case Examineness.ComplexWildcard:
- queryToAdd = this.queryParser.GetWildcardQuery(fieldName, fieldValue.Value);
- break;
- case Examineness.Boosted:
- queryToAdd = this.queryParser.GetFieldQuery(fieldName, fieldValue.Value);
- queryToAdd.SetBoost(fieldValue.Level);
- break;
- case Examineness.Proximity:
- //This is how you are supposed to do this based on this doc here:
- //http://lucene.apache.org/java/2_4_1/api/org/apache/lucene/search/spans/package-summary.html#package_description
- //but i think that lucene.net has an issue with it's internal parser since it parses to a very strange query
- //we'll just manually make it instead below
-
- //var spans = new List();
- //foreach (var s in fieldValue.Value.Split(' '))
- //{
- // spans.Add(new SpanTermQuery(new Term(fieldName, s)));
- //}
- //queryToAdd = new SpanNearQuery(spans.ToArray(), Convert.ToInt32(fieldValue.Level), true);
-
- var proxQuery = fieldName + ":\"" + fieldValue.Value + "\"~" + Convert.ToInt32(fieldValue.Level).ToString();
- queryToAdd = queryParser.Parse(proxQuery);
-
- break;
- case Examineness.Explicit:
- default:
- queryToAdd = this.queryParser.GetFieldQuery(fieldName, fieldValue.Value);
- break;
- }
- return queryToAdd;
- }
-
- internal protected IBooleanOperation FieldInternal(string fieldName, IExamineValue fieldValue, BooleanClause.Occur occurance)
- {
- Query queryToAdd = GetFieldInternalQuery(fieldName, fieldValue);
-
- if (queryToAdd != null)
- query.Add(queryToAdd, occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- public IBooleanOperation Range(string fieldName, DateTime start, DateTime end)
- {
- return this.Range(fieldName, start, end, true, true);
- }
-
- public IBooleanOperation Range(string fieldName, DateTime start, DateTime end, bool includeLower, bool includeUpper)
- {
- //since lucene works on string's for all searching we need to flatten the date
- return this.RangeInternal(fieldName, DateTools.DateToString(start, DateTools.Resolution.MILLISECOND), DateTools.DateToString(end, DateTools.Resolution.MILLISECOND), includeLower, includeUpper, occurance);
- }
-
- public IBooleanOperation Range(string fieldName, int start, int end)
- {
- Enforcer.ArgumentNotNull(fieldName, "fieldName");
- return this.Range(fieldName, start, end, true, true);
- }
-
- public IBooleanOperation Range(string fieldName, int start, int end, bool includeLower, bool includeUpper)
- {
- return this.RangeInternal(fieldName, start, end, includeLower, includeUpper, occurance);
- }
-
- protected internal IBooleanOperation RangeInternal(string fieldName, int start, int end, bool includeLower, bool includeUpper, BooleanClause.Occur occurance)
- {
- query.Add(NumericRangeQuery.NewIntRange(fieldName, start, end, includeLower, includeUpper), occurance);
- return new LuceneBooleanOperation(this);
- }
-
- public IBooleanOperation Range(string fieldName, string start, string end)
- {
- Enforcer.ArgumentNotNull(fieldName, "fieldName");
- Enforcer.ArgumentNotNull(start, "start");
- Enforcer.ArgumentNotNull(end, "end");
- return this.Range(fieldName, start, end, true, true);
- }
-
- public IBooleanOperation Range(string fieldName, string start, string end, bool includeLower, bool includeUpper)
- {
- Enforcer.ArgumentNotNull(fieldName, "fieldName");
- Enforcer.ArgumentNotNull(start, "start");
- Enforcer.ArgumentNotNull(end, "end");
- return this.RangeInternal(fieldName, start, end, includeLower, includeUpper, occurance);
- }
-
- protected internal IBooleanOperation RangeInternal(string fieldName, string start, string end, bool includeLower, bool includeUpper, BooleanClause.Occur occurance)
- {
- query.Add(new TermRangeQuery(fieldName, start, end, includeLower, includeUpper), occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- public IBooleanOperation GroupedAnd(IEnumerable fields, params string[] query)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "query");
-
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
- return this.GroupedAnd(fields.ToArray(), fieldVals.ToArray());
- }
-
- public IBooleanOperation GroupedAnd(IEnumerable fields, IExamineValue[] fieldVals)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "fieldVals");
-
- return this.GroupedAndInternal(fields.ToArray(), fieldVals.ToArray(), occurance);
- }
-
- protected internal IBooleanOperation GroupedAndInternal(string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance)
- {
-
- //if there's only 1 query text we want to build up a string like this:
- //(+field1:query +field2:query +field3:query)
- //but Lucene will bork if you provide an array of length 1 (which is != to the field length)
-
- query.Add(GetMultiFieldQuery(fields, fieldVals, BooleanClause.Occur.MUST), occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- public IBooleanOperation GroupedOr(IEnumerable fields, params string[] query)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "query");
-
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
-
- return this.GroupedOr(fields.ToArray(), fieldVals.ToArray());
- }
-
- public IBooleanOperation GroupedOr(IEnumerable fields, params IExamineValue[] fieldVals)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "query");
-
- return this.GroupedOrInternal(fields.ToArray(), fieldVals, occurance);
- }
-
- protected internal IBooleanOperation GroupedOrInternal(string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance)
- {
- //if there's only 1 query text we want to build up a string like this:
- //(field1:query field2:query field3:query)
- //but Lucene will bork if you provide an array of length 1 (which is != to the field length)
-
- query.Add(GetMultiFieldQuery(fields, fieldVals, BooleanClause.Occur.SHOULD), occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- public IBooleanOperation GroupedNot(IEnumerable fields, params string[] query)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "query");
-
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
-
- return this.GroupedNot(fields.ToArray(), fieldVals.ToArray());
- }
-
- public IBooleanOperation GroupedNot(IEnumerable fields, params IExamineValue[] query)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "query");
-
- return this.GroupedNotInternal(fields.ToArray(), query, occurance);
- }
-
- protected internal IBooleanOperation GroupedNotInternal(string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance)
- {
- //if there's only 1 query text we want to build up a string like this:
- //(!field1:query !field2:query !field3:query)
- //but Lucene will bork if you provide an array of length 1 (which is != to the field length)
-
- query.Add(GetMultiFieldQuery(fields, fieldVals, BooleanClause.Occur.MUST_NOT), occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- ///
- /// Creates our own style 'multi field query' used internal for the grouped operations
- ///
- ///
- ///
- ///
- /// A new with the clause appended
- protected internal BooleanQuery GetMultiFieldQuery(string[] fields, IExamineValue[] fieldVals, BooleanClause.Occur occurance)
- {
- //if there's only 1 query text we want to build up a string like this:
- //(!field1:query !field2:query !field3:query)
- //but Lucene will bork if you provide an array of length 1 (which is != to the field length)
-
- var queryVals = new IExamineValue[fields.Length];
- if (fieldVals.Length == 1)
- {
- for (int i = 0; i < queryVals.Length; i++)
- queryVals[i] = fieldVals[0];
- }
- else
- {
- queryVals = fieldVals;
- }
-
- var qry = new BooleanQuery();
- for (int i = 0; i < fields.Length; i++)
- {
- qry.Add(this.GetFieldInternalQuery(fields[i], queryVals[i]), occurance);
- }
-
- return qry;
- }
-
- public IBooleanOperation GroupedFlexible(IEnumerable fields, IEnumerable operations, params string[] query)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "query");
- Enforcer.ArgumentNotNull(operations, "operations");
-
- var fieldVals = new List();
- foreach (var f in query)
- {
- fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
- }
-
- return this.GroupedFlexible(fields.ToArray(), operations.ToArray(), fieldVals.ToArray());
- }
-
- public IBooleanOperation GroupedFlexible(IEnumerable fields, IEnumerable operations, params IExamineValue[] fieldVals)
- {
- Enforcer.ArgumentNotNull(fields, "fields");
- Enforcer.ArgumentNotNull(query, "query");
- Enforcer.ArgumentNotNull(operations, "operations");
-
- return this.GroupedFlexibleInternal(fields.ToArray(), operations.ToArray(), fieldVals, occurance);
- }
-
- protected internal IBooleanOperation GroupedFlexibleInternal(string[] fields, BooleanOperation[] operations, IExamineValue[] fieldVals, BooleanClause.Occur occurance)
- {
- //if there's only 1 query text we want to build up a string like this:
- //(field1:query field2:query field3:query)
- //but Lucene will bork if you provide an array of length 1 (which is != to the field length)
-
- var flags = new BooleanClause.Occur[operations.Count()];
- for (int i = 0; i < flags.Length; i++)
- flags[i] = operations.ElementAt(i).ToLuceneOccurance();
-
- var queryVals = new IExamineValue[fields.Length];
- if (fieldVals.Length == 1)
- {
- for (int i = 0; i < queryVals.Length; i++)
- queryVals[i] = fieldVals[0];
- }
- else
- {
- queryVals = fieldVals;
- }
-
- var qry = new BooleanQuery();
- for (int i = 0; i < fields.Length; i++)
- {
- qry.Add(this.GetFieldInternalQuery(fields[i], queryVals[i]), flags[i]);
- }
-
- this.query.Add(qry, occurance);
-
- return new LuceneBooleanOperation(this);
- }
-
- ///
- /// Passes a raw search query to the provider to handle
- ///
- /// The query.
- /// A new with the clause appended
- public ISearchCriteria RawQuery(string query)
- {
- this.query.Add(this.queryParser.Parse(query), this.occurance);
-
- return this;
- }
-
- ///
- /// Orders the results by the specified fields
- ///
- /// The field names.
- /// A new with the clause appended
- public IBooleanOperation OrderBy(params string[] fieldNames)
- {
- Enforcer.ArgumentNotNull(fieldNames, "fieldNames");
-
- return this.OrderByInternal(false, fieldNames);
- }
-
- ///
- /// Orders the results by the specified fields in a descending order
- ///
- /// The field names.
- /// A new with the clause appended
- public IBooleanOperation OrderByDescending(params string[] fieldNames)
- {
- Enforcer.ArgumentNotNull(fieldNames, "fieldNames");
-
- return this.OrderByInternal(true, fieldNames);
- }
-
- ///
- /// Internal operation for adding the ordered results
- ///
- /// if set to true [descending].
- /// The field names.
- /// A new with the clause appended
- protected internal IBooleanOperation OrderByInternal(bool descending, params string[] fieldNames)
- {
- foreach (var fieldName in fieldNames)
- {
- this.sortFields.Add(new SortField(LuceneExamineIndexer.SortedFieldNamePrefix + fieldName, SortField.STRING, descending));
- }
-
- return new LuceneBooleanOperation(this);
- }
-
- #endregion
- }
-}
diff --git a/src/UmbracoExamine/SearchCriteria/LuceneSearchExtensions.cs b/src/UmbracoExamine/SearchCriteria/LuceneSearchExtensions.cs
deleted file mode 100644
index 3681c98e47..0000000000
--- a/src/UmbracoExamine/SearchCriteria/LuceneSearchExtensions.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-using Examine.SearchCriteria;
-using Lucene.Net.Search;
-using Lucene.Net.QueryParsers;
-using System;
-
-namespace UmbracoExamine.SearchCriteria
-{
- public static class LuceneSearchExtensions
- {
- ///
- /// Adds a single character wildcard to the string for Lucene wildcard matching
- ///
- /// The string to wildcard.
- /// An IExamineValue for the required operation
- /// Thrown when the string is null or empty
- public static IExamineValue SingleCharacterWildcard(this string s)
- {
- if (System.String.IsNullOrEmpty(s))
- throw new ArgumentException("Supplied string is null or empty.", "s");
-
- return new ExamineValue(Examineness.SimpleWildcard, s + "?");
- }
-
- ///
- /// Adds a multi-character wildcard to a string for Lucene wildcard matching
- ///
- /// The string to wildcard.
- /// An IExamineValue for the required operation
- /// Thrown when the string is null or empty
- public static IExamineValue MultipleCharacterWildcard(this string s)
- {
- if (String.IsNullOrEmpty(s))
- throw new ArgumentException("Supplied string is null or empty.", "s");
- return new ExamineValue(Examineness.ComplexWildcard, s + "*");
- }
-
- ///
- /// Configures the string for fuzzy matching in Lucene using the default fuzziness level
- ///
- /// The string to configure fuzzy matching on.
- /// An IExamineValue for the required operation
- /// Thrown when the string is null or empty
- public static IExamineValue Fuzzy(this string s)
- {
- return Fuzzy(s, 0.5f);
- }
-
- ///
- /// Configures the string for fuzzy matching in Lucene using the supplied fuzziness level
- ///
- /// The string to configure fuzzy matching on.
- /// The fuzzieness level.
- ///
- /// An IExamineValue for the required operation
- ///
- /// Thrown when the string is null or empty
- public static IExamineValue Fuzzy(this string s, float fuzzieness)
- {
- if (String.IsNullOrEmpty(s))
- throw new ArgumentException("Supplied string is null or empty.", "s");
- return new ExamineValue(Examineness.Fuzzy, s, fuzzieness);
- }
-
- ///
- /// Configures the string for boosting in Lucene
- ///
- /// The string to wildcard.
- /// The boost level.
- ///
- /// An IExamineValue for the required operation
- ///
- /// Thrown when the string is null or empty
- public static IExamineValue Boost(this string s, float boost)
- {
- if (String.IsNullOrEmpty(s))
- throw new ArgumentException("Supplied string is null or empty.", "s");
- return new ExamineValue(Examineness.Boosted, s + "^", boost);
- }
-
- ///
- /// Configures the string for proximity matching
- ///
- /// The string to wildcard.
- /// The proximity level.
- ///
- /// An IExamineValue for the required operation
- ///
- /// Thrown when the string is null or empty
- public static IExamineValue Proximity(this string s, int proximity)
- {
- if (String.IsNullOrEmpty(s))
- throw new ArgumentException("Supplied string is null or empty.", "s");
- return new ExamineValue(Examineness.Proximity, s + "~", Convert.ToSingle(proximity));
- }
-
- ///
- /// Escapes the string within Lucene
- ///
- /// The string to wildcard.
- /// An IExamineValue for the required operation
- /// Thrown when the string is null or empty
- public static IExamineValue Escape(this string s)
- {
- if (String.IsNullOrEmpty(s))
- throw new ArgumentException("Supplied string is null or empty.", "s");
- return new ExamineValue(Examineness.Escaped, QueryParser.Escape(s));
- }
-
- ///
- /// Sets up an for an additional Examiness
- ///
- /// The IExamineValue to continue working with.
- /// The string to postfix.
- /// Combined strings
- public static string Then(this IExamineValue examineValue, string s)
- {
- if (examineValue == null)
- throw new ArgumentNullException("examineValue", "examineValue is null.");
- if (String.IsNullOrEmpty(s))
- throw new ArgumentException("Supplied string is null or empty.", "s");
- return examineValue.Value + s;
- }
-
- ///
- /// Converts an Examine boolean operation to a Lucene representation
- ///
- /// The operation.
- /// The translated Boolean operation
- public static BooleanClause.Occur ToLuceneOccurance(this BooleanOperation o)
- {
- switch (o)
- {
- case BooleanOperation.And:
- return BooleanClause.Occur.MUST;
- case BooleanOperation.Not:
- return BooleanClause.Occur.MUST_NOT;
- case BooleanOperation.Or:
- default:
- return BooleanClause.Occur.SHOULD;
- }
- }
-
- ///
- /// Converts a Lucene boolean occurrence to an Examine representation
- ///
- /// The occurrence to translate.
- /// The translated boolean occurrence
- public static BooleanOperation ToBooleanOperation(this BooleanClause.Occur o)
- {
- if (o == BooleanClause.Occur.MUST)
- {
- return BooleanOperation.And;
- }
- else if (o == BooleanClause.Occur.MUST_NOT)
- {
- return BooleanOperation.Not;
- }
- else
- {
- return BooleanOperation.Or;
- }
- }
- }
-}