Exemplo n.º 1
0
        public Core.SFQL.Parse.DocumentResultWhereDictionary Search()
        {
            Query.PerformanceReport performanceReport = new Hubble.Core.Query.PerformanceReport("Search of Match1");

            Core.SFQL.Parse.DocumentResultWhereDictionary result = new Core.SFQL.Parse.DocumentResultWhereDictionary();

            if (_QueryWords.Count <= 0 || _WordIndexes.Length <= 0)
            {
                if (_QueryParameter.Not && UpDict != null)
                {
                    return(UpDict);
                }
                else
                {
                    return(result);
                }
            }

            if (this._QueryParameter.Not)
            {
                if (_InvertedIndex.IndexMode == Field.IndexMode.Simple)
                {
                    Calculate(null, ref result, _WordIndexes);
                }
                else
                {
                    CalculateWithPosition(null, ref result, _WordIndexes);
                }
            }
            else
            {
                if (_InvertedIndex.IndexMode == Field.IndexMode.Simple)
                {
                    Calculate(this.UpDict, ref result, _WordIndexes);
                }
                else
                {
                    CalculateWithPosition(this.UpDict, ref result, _WordIndexes);
                }
            }

            if (this._QueryParameter.Not)
            {
                result.Not = true;

                if (UpDict != null)
                {
                    result = result.AndMergeForNot(result, UpDict);
                }
            }

            performanceReport.Stop();

            return(result);
        }
Exemplo n.º 2
0
        public Core.SFQL.Parse.DocumentResultWhereDictionary Search()
        {
            Query.PerformanceReport performanceReport = new Hubble.Core.Query.PerformanceReport("Search of Contains");

            List <WordIndexForQuery[]> partList = GetAllPartOfWordIndexes();

            if (_QueryWords.Count <= 0 || partList.Count <= 0)
            {
                return(PartSearch(new WordIndexForQuery[0]));
            }


            Core.SFQL.Parse.DocumentResultWhereDictionary result = PartSearch(partList[0]);

            for (int i = 1; i < partList.Count; i++)
            {
                bool someWordNoResult = false;

                foreach (WordIndexForQuery w in partList[i])
                {
                    if (w.WordIndex.WordCount == 0)
                    {
                        someWordNoResult = true;
                        break;
                    }

                    w.WordIndex.Reset();
                }

                if (!someWordNoResult)
                {
                    result.OrMerge(result, PartSearch(partList[i]));
                }
            }

            if (this._QueryParameter.Not)
            {
                result.Not = true;

                if (UpDict != null)
                {
                    result = result.AndMergeForNot(result, UpDict);
                }
            }

            performanceReport.Stop();

            return(result);
        }
Exemplo n.º 3
0
        public Core.SFQL.Parse.DocumentResultWhereDictionary Search()
        {
            Query.PerformanceReport performanceReport = new Hubble.Core.Query.PerformanceReport("Search of Match");

            Init();

            Core.SFQL.Parse.DocumentResultWhereDictionary result = new Core.SFQL.Parse.DocumentResultWhereDictionary();

            if (_QueryWords.Count <= 0 || _WordIndexes.Length <= 0)
            {
                if (_QueryParameter.Not && UpDict != null)
                {
                    return(UpDict);
                }
                else
                {
                    return(result);
                }
            }

            if (this._QueryParameter.Not)
            {
                if (_InvertedIndex.IndexMode == Field.IndexMode.Simple)
                {
                    Calculate(null, ref result, _WordIndexes);
                }
                else
                {
                    //For not, we have to return all of the records
                    //Modified at 18 Jan 2012
                    CalculateWithPosition(null, ref result, _WordIndexes);

                    //if (Optimize.OptimizeArgument.IsOrderByScoreDesc(this._QueryParameter.OrderBys) &&
                    //    !this._QueryParameter.NeedDistinct && this._QueryParameter.CanLoadPartOfDocs
                    //    && this._QueryParameter.AndExpressionCanBeOptimized(_DBProvider)
                    //    && _WordIndexes.Length > 1 && this.UpDict == null)
                    //{
                    //    CalculateWithPositionOrderByScoreDesc(null, ref result, _WordIndexes);
                    //}
                    //else
                    //{
                    //    CalculateWithPosition(null, ref result, _WordIndexes);
                    //}
                }
            }
            else
            {
                if (_InvertedIndex.IndexMode == Field.IndexMode.Simple)
                {
                    Calculate(this.UpDict, ref result, _WordIndexes);
                }
                else
                {
                    if (//Optimize.OptimizeArgument.IsOrderByScoreDesc(this._QueryParameter.OrderBys) &&
                        !this._QueryParameter.NeedDistinct && this._QueryParameter.CanLoadPartOfDocs &&
                        this._QueryParameter.AndExpressionCanBeOptimized(_DBProvider) &&
                        _WordIndexes.Length > 1 && this.UpDict == null)
                    {
                        IQueryOptimize qOptimize = QueryOptimizeBuilder.Build(typeof(MatchOptimize),
                                                                              DBProvider, _QueryParameter.End, _QueryParameter.OrderBy,
                                                                              _QueryParameter.OrderBys, _QueryParameter.NeedGroupBy,
                                                                              _QueryParameter.OrderByCanBeOptimized, _QueryParameter.NeedFilterUntokenizedConditions(this._DBProvider),
                                                                              _QueryParameter.UntokenizedTreeOnRoot, _WordIndexes);

                        Query.PerformanceReport performanceReportCalculate = null;

                        try
                        {
                            performanceReportCalculate = new Hubble.Core.Query.PerformanceReport("Calculate");

                            qOptimize.CalculateOptimize(this.UpDict, ref result);
                        }
                        finally
                        {
                            performanceReportCalculate.Stop();
                        }
                    }
                    else
                    {
                        CalculateWithPosition(this.UpDict, ref result, _WordIndexes);
                    }
                }
            }

            if (this._QueryParameter.Not)
            {
                result.Not = true;

                if (UpDict != null)
                {
                    result = result.AndMergeForNot(result, UpDict);
                }
            }

            performanceReport.Stop();

            return(result);
        }