Beispiel #1
0
        public IBooleanOperation GroupedNot(IEnumerable <string> fields, params IExamineValue[] query)
        {
            Enforcer.ArgumentNotNull(fields, "fields");
            Enforcer.ArgumentNotNull(query, "query");

            return(this.GroupedNotInternal(fields.ToArray(), query));
        }
Beispiel #2
0
 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));
 }
Beispiel #3
0
        public IBooleanOperation GroupedOr(IEnumerable <string> fields, params IExamineValue[] fieldVals)
        {
            Enforcer.ArgumentNotNull(fields, "fields");
            Enforcer.ArgumentNotNull(Query, "query");

            return(this.GroupedOrInternal(fields.ToArray(), fieldVals, _occurance));
        }
Beispiel #4
0
 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));
 }
        public override ISearchResults Search(ISearchCriteria searchParams, int maxResults)
        {
            Enforcer.ArgumentNotNull(searchParams, "searchParams");

            var luceneParams = searchParams as LuceneSearchCriteria;

            if (luceneParams == null)
            {
                throw new ArgumentException("Provided ISearchCriteria dos not match the allowed ISearchCriteria. Ensure you only use an ISearchCriteria created from the current SearcherProvider");
            }

            //check if we are sorting on Score, if so we'll need to set a lucene config switch
            if (luceneParams.SortFields.Count == 0)
            {
                SetScoringBooleanQueryRewriteMethod(luceneParams.Query);
            }

            var searcher = GetSearcher();

            if (searcher == null)
            {
                return(new EmptySearchResults());
            }

            var pagesResults = new SearchResults(luceneParams.Query, luceneParams.SortFields, searcher, maxResults);

            return(pagesResults);
        }
        public IBooleanOperation GroupedAnd(IEnumerable <string> fields, IExamineValue[] fieldVals)
        {
            Enforcer.ArgumentNotNull(fields, "fields");
            Enforcer.ArgumentNotNull(query, "fieldVals");

            return(this.GroupedAndInternal(fields.ToArray(), fieldVals.ToArray(), occurance));
        }
        public IBooleanOperation GroupedFlexible(IEnumerable <string> fields, IEnumerable <BooleanOperation> 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));
        }
Beispiel #8
0
        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();
        }
Beispiel #9
0
        public IBooleanOperation GroupedAnd(IEnumerable <string> fields, params string[] query)
        {
            Enforcer.ArgumentNotNull(fields, "fields");
            Enforcer.ArgumentNotNull(query, "query");

            var fieldVals = new List <IExamineValue>();

            foreach (var f in query)
            {
                fieldVals.Add(new ExamineValue(Examineness.Explicit, f));
            }
            return(this.GroupedAnd(fields.ToArray(), fieldVals.ToArray()));
        }
Beispiel #10
0
        internal LuceneSearchCriteria(string type, Analyzer analyzer, string[] fields, bool allowLeadingWildcards, BooleanOperation occurance)
        {
            //TODO: It would be nice to be able to pass in the existing field definitions here so
            // we'd know what fields have sorting enabled so we don't have to use the special sorting syntax for field types

            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();
        }
        public override ISearchResults Search(ISearchCriteria searchParams, int maxResults)
        {
            Enforcer.ArgumentNotNull(searchParams, "searchParams");

            var luceneParams = searchParams as LuceneSearchCriteria;

            if (luceneParams == null)
            {
                throw new ArgumentException("Provided ISearchCriteria dos not match the allowed ISearchCriteria. Ensure you only use an ISearchCriteria created from the current SearcherProvider");
            }

            var searcher     = GetSearcher();
            var pagesResults = new SearchResults(luceneParams.Query, luceneParams.SortFields, searcher, maxResults);

            return(pagesResults);
        }
Beispiel #12
0
 public IBooleanOperation Field(string fieldName, IExamineValue fieldValue)
 {
     Enforcer.ArgumentNotNull(fieldName, "fieldName");
     Enforcer.ArgumentNotNull(fieldValue, "fieldValue");
     return(this.FieldInternal(fieldName, fieldValue, _occurance));
 }
Beispiel #13
0
 public IBooleanOperation NodeTypeAlias(IExamineValue nodeTypeAlias)
 {
     Enforcer.ArgumentNotNull(nodeTypeAlias, "nodeTypeAlias");
     return(this.NodeTypeAliasInternal(nodeTypeAlias, _occurance));
 }
Beispiel #14
0
 /// <summary>
 /// Query on the NodeTypeAlias
 /// </summary>
 /// <param name="nodeTypeAlias">The node type alias.</param>
 /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns>
 public IBooleanOperation NodeTypeAlias(string nodeTypeAlias)
 {
     Enforcer.ArgumentNotNull(nodeTypeAlias, "nodeTypeAlias");
     return(this.NodeTypeAlias(new ExamineValue(Examineness.Explicit, nodeTypeAlias)));
 }
Beispiel #15
0
 public IBooleanOperation NodeName(IExamineValue nodeName)
 {
     Enforcer.ArgumentNotNull(nodeName, "nodeName");
     return(this.NodeNameInternal(nodeName, _occurance));
 }
Beispiel #16
0
 /// <summary>
 /// Query on the NodeName
 /// </summary>
 /// <param name="nodeName">Name of the node.</param>
 /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns>
 public IBooleanOperation NodeName(string nodeName)
 {
     Enforcer.ArgumentNotNull(nodeName, "nodeName");
     return(NodeName(new ExamineValue(Examineness.Explicit, nodeName)));
 }
Beispiel #17
0
        /// <summary>
        /// Orders the results by the specified fields in a descending order
        /// </summary>
        /// <param name="fieldNames">The field names.</param>
        /// <returns>A new <see cref="Examine.SearchCriteria.IBooleanOperation"/> with the clause appended</returns>
        public IBooleanOperation OrderByDescending(params string[] fieldNames)
        {
            Enforcer.ArgumentNotNull(fieldNames, "fieldNames");

            return(this.OrderByInternal(true, fieldNames));
        }
Beispiel #18
0
 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));
 }