コード例 #1
0
#pragma warning restore 612, 618

        private static void Search(Index.IndexReader r, int times)
        {
            var searcher = new Search.IndexSearcher(r);
            var docs     = new System.Collections.Generic.List <Documents.Document>(10000);

            for (int i = 0; i < times; i++)
            {
                var q = new Search.TermQuery(new Index.Term("title", "volume"));
                foreach (var scoreDoc in searcher.Search(q, 100).ScoreDocs)
                {
                    docs.Add(searcher.Doc(scoreDoc.Doc));
                }
            }
        }
コード例 #2
0
        public override DocIdSet GetDocIdSet(Index.IndexReader reader, IState state)
        {
            var values = source.GetValues(reader, state);

            return(new ValueSourceFilteredDocIdSet(startingFilter.GetDocIdSet(reader, state), values, this));
        }
コード例 #3
0
		public override DocIdSet GetDocIdSet(Index.IndexReader reader /*, Bits acceptDocs*/)
		{
			var bits = new OpenBitSet(reader.MaxDoc);
			var terms = new TermsEnumCompatibility(reader, fieldName);
			var term = terms.Next();
			if (term == null)
				return null;
			Node scanCell = null;

			//cells is treated like a stack. LinkedList conveniently has bulk add to beginning. It's in sorted order so that we
			//  always advance forward through the termsEnum index.
			var cells = new LinkedList<Node>(
				grid.GetWorldNode().GetSubCells(queryShape));

			//This is a recursive algorithm that starts with one or more "big" cells, and then recursively dives down into the
			// first such cell that intersects with the query shape.  It's a depth first traversal because we don't move onto
			// the next big cell (breadth) until we're completely done considering all smaller cells beneath it. For a given
			// cell, if it's *within* the query shape then we can conveniently short-circuit the depth traversal and
			// grab all documents assigned to this cell/term.  For an intersection of the cell and query shape, we either
			// recursively step down another grid level or we decide heuristically (via prefixGridScanLevel) that there aren't
			// that many points, and so we scan through all terms within this cell (i.e. the term starts with the cell's term),
			// seeing which ones are within the query shape.
			while (cells.Count > 0)
			{
				Node cell = cells.First.Value; cells.RemoveFirst();
				var cellTerm = cell.GetTokenString();
				var seekStat = terms.Seek(cellTerm);
				if (seekStat == TermsEnumCompatibility.SeekStatus.END)
					break;
				if (seekStat == TermsEnumCompatibility.SeekStatus.NOT_FOUND)
					continue;
				if (cell.GetLevel() == detailLevel || cell.IsLeaf())
				{
					terms.Docs(bits);
				}
				else
				{//any other intersection
					//If the next indexed term is the leaf marker, then add all of them
					var nextCellTerm = terms.Next();
					Debug.Assert(nextCellTerm.Text.StartsWith(cellTerm));
					scanCell = grid.GetNode(nextCellTerm.Text, scanCell);
					if (scanCell.IsLeaf())
					{
						terms.Docs(bits);
						term = terms.Next();//move pointer to avoid potential redundant addDocs() below
					}

					//Decide whether to continue to divide & conquer, or whether it's time to scan through terms beneath this cell.
					// Scanning is a performance optimization trade-off.
					bool scan = cell.GetLevel() >= prefixGridScanLevel;//simple heuristic

					if (!scan)
					{
						//Divide & conquer
						var lst = cell.GetSubCells(queryShape);
						for (var i = lst.Count - 1; i >= 0; i--) //add to beginning
						{
							cells.AddFirst(lst[i]);
						}
					}
					else
					{
						//Scan through all terms within this cell to see if they are within the queryShape. No seek()s.
						for (var t = terms.Term(); t != null && t.Text.StartsWith(cellTerm); t = terms.Next())
						{
							scanCell = grid.GetNode(t.Text, scanCell);
							int termLevel = scanCell.GetLevel();
							if (termLevel > detailLevel)
								continue;
							if (termLevel == detailLevel || scanCell.IsLeaf())
							{
								//TODO should put more thought into implications of box vs point
								Shape cShape = termLevel == grid.GetMaxLevels() ? scanCell.GetCenter() : scanCell.GetShape();
                                if (queryShape.Relate(cShape) == SpatialRelation.DISJOINT)
									continue;

								terms.Docs(bits);
							}
						}//term loop
					}
				}
			}//cell loop

			return bits;
		}
コード例 #4
0
ファイル: FunctionQuery.cs プロジェクト: ravendb/lucenenet
 public override Query Rewrite(Index.IndexReader reader, IState state)
 {
     return(this);
 }
コード例 #5
0
 public override Query Rewrite(Index.IndexReader reader)
 {
     return(this);
 }
コード例 #6
0
 public override void SetNextReader(Index.IndexReader reader, int base_Renamed)
 {
     base.SetNextReader(reader, base_Renamed);
     this._afterDoc = this._after.Doc - base_Renamed;
 }
コード例 #7
0
 public override Search.Query Rewrite(Index.IndexReader reader)
 {
     return(m_srndQuery.GetSpanNearQuery(reader, m_fieldName, Boost, m_qf));
 }