public LatLongDistanceFilter(Filter startingFilter, double distance, double lat, double lng, string latField, string lngField) : base(startingFilter, distance)
		{
			_lat = lat;
			_lngField = lngField;
			_latField = latField;
			_lng = lng;
		}
 internal Hits(Searcher s, Query q, Filter f)
 {
     weight = q.Weight(s);
     searcher = s;
     filter = f;
     GetMoreDocs(50); // retrieve 100 initially
 }
 /// <summary>
 /// Create a ToChildBlockJoinQuery.
 /// </summary>
 /// <param name="parentQuery">Query that matches parent documents</param>
 /// <param name="parentsFilter">Filter (must produce FixedBitSet per-segment, like <see cref="FixedBitSetCachingWrapperFilter"/>) 
 /// identifying the parent documents.</param>
 /// <param name="doScores">True if parent scores should be calculated.</param>
 public ToChildBlockJoinQuery(Query parentQuery, Filter parentsFilter, bool doScores)
 {
     _origParentQuery = parentQuery;
     _parentQuery = parentQuery;
     _parentsFilter = parentsFilter;
     _doScores = doScores;
 }
        /// <summary>
        /// 构建Query、Filter、Sort
        /// </summary>
        /// <param name="query"><see cref="Query"/></param>
        /// <param name="filter"><see cref="Filter"/></param>
        /// <param name="sort"><see cref="Sort"/></param>
        public void BuildQuery(out Query query, out Filter filter, out Sort sort)
        {
            BooleanQuery q = new BooleanQuery();
            foreach (var clause in clauses)
            {
                q.Add(clause);
            }
            query = q;

            if (filters.Count > 0)
            {
                BooleanQuery filterQuery = new BooleanQuery();
                foreach (var _filter in filters)
                    filterQuery.Add(_filter);

                filter = new QueryWrapperFilter(filterQuery);
            }
            else
            {
                filter = null;
            }

            if (sortFields.Count > 0)
                sort = new Sort(sortFields.ToArray());
            else
                sort = null;
        }
        public void SearchFiltered(IndexWriter writer, Directory directory, Filter filter, bool optimize)
        {
            try
            {
                for (int i = 0; i < 60; i++)
                {//Simple docs
                    Document doc = new Document();
                    doc.Add(new Field(FIELD, i.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                    writer.AddDocument(doc);
                }
                if (optimize)
                    writer.Optimize();
                writer.Close();

                BooleanQuery booleanQuery = new BooleanQuery();
                booleanQuery.Add(new TermQuery(new Term(FIELD, "36")), Occur.SHOULD);


                IndexSearcher indexSearcher = new IndexSearcher(directory);
                ScoreDoc[] hits = indexSearcher.Search(booleanQuery, filter, 1000).ScoreDocs;
                Assert.AreEqual(1, hits.Length, "Number of matched documents");

            }
            catch (System.IO.IOException e)
            {
                Assert.Fail(e.Message);
            }

        }
        private void SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
        {
            DocIdSet docIdSet = filter.GetDocIdSet(reader);
            if (docIdSet == null)
                return;
            Scorer scorer = weight.Scorer(reader, true, false);
            if (scorer == null)
                return;
            scorer.DocID();

            DocIdSetIterator docIdSetIterator = docIdSet.Iterator();
            if (docIdSetIterator == null)
                return;
            int target = docIdSetIterator.NextDoc();
            int num = scorer.Advance(target);
            collector.SetScorer(scorer);
            while (true)
            {
                while (num != target)
                {
                    if (num > target)
                        target = docIdSetIterator.Advance(num);
                    else
                        num = scorer.Advance(target);
                }
                if (num != DocIdSetIterator.NO_MORE_DOCS && !((GroupCollector)collector).GroupLimitReached)
                {
                    collector.Collect(num);
                    target = docIdSetIterator.NextDoc();
                    num = scorer.Advance(target);
                }
                else
                    break;
            }
        }
 public static OpenBitSet CreateBitSet(IndexReader reader, Filter filter)
 {
     IndexSearcher searcher = new IndexSearcher(reader);
     OpenBitSet result = new OpenBitSet();
     searcher.Search(new MatchAllDocsQuery(), filter, new BitSetCollector(result));
     return result;
 }
        // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 

        protected override void Warm(IndexSearcher searcher)
        {
            searcher.Search(new MatchAllDocsQuery(), 1);

            // Create the tenant filters
            _filters = new Dictionary<string, Filter>();
            IEnumerable<string> tenantIds = PackageTenantId.GetDistintTenantId(searcher.IndexReader);
            foreach (string tenantId in tenantIds)
            {
                _filters.Add(tenantId, new CachingWrapperFilter(new TenantFilter(tenantId)));
            }
            _publicFilter = new CachingWrapperFilter(new PublicFilter());

            _latestVersion = new CachingWrapperFilter(LatestVersionFilter.Create(searcher.IndexReader, false, false));
            _latestVersionIncludeUnlisted = new CachingWrapperFilter(LatestVersionFilter.Create(searcher.IndexReader, false, true));
            _latestVersionIncludePrerelease = new CachingWrapperFilter(LatestVersionFilter.Create(searcher.IndexReader, true, false));
            _latestVersionIncludePrereleaseIncludeUnlisted = new CachingWrapperFilter(LatestVersionFilter.Create(searcher.IndexReader, true, true));

            // Recalculate precalculated Versions arrays 
            PackageVersions packageVersions = new PackageVersions(searcher.IndexReader);
            _versionsByDoc = packageVersions.CreateVersionsLookUp(null);
            _versionListsByDoc = packageVersions.CreateVersionListsLookUp();

            // Set metadata
            LastReopen = DateTime.UtcNow;
            NumDocs = searcher.IndexReader.NumDocs();
            CommitUserData = searcher.IndexReader.CommitUserData;
        }
 /// <summary>
 /// Create ToParentBlockJoinSortField.
 /// </summary>
 /// <param name="field"> The sort field on the nested / child level. </param>
 /// <param name="type"> The sort type on the nested / child level. </param>
 /// <param name="reverse"> Whether natural order should be reversed on the nested / child document level. </param>
 /// <param name="order"> Whether natural order should be reversed on the parent level. </param>
 /// <param name="parentFilter"> Filter that identifies the parent documents. </param>
 /// <param name="childFilter"> Filter that defines which child documents participates in sorting. </param>
 public ToParentBlockJoinSortField(string field, Type_e type, bool reverse, bool order, Filter parentFilter, Filter childFilter) 
     : base(field, type, reverse)
 {
     Order = order;
     ParentFilter = parentFilter;
     ChildFilter = childFilter;
 }
 private ToChildBlockJoinQuery(Query origParentQuery, Query parentQuery, Filter parentsFilter, bool doScores)
     : base()
 {
     _origParentQuery = origParentQuery;
     _parentQuery = parentQuery;
     _parentsFilter = parentsFilter;
     _doScores = doScores;
 }
        public FacetMatcher(Filter query, IndexReader indexReader)
        {
            Throw.IfArgumentNull(query);
            Throw.IfArgumentNull(indexReader);

            this._query = query;
            this._indexReader = indexReader;
        }
 public BrowseRequest()
 {
     selections = new Dictionary<string, BrowseSelection>();
     sortFields = new List<SortField>();
     FacetSpecs = new Dictionary<string, FacetSpec>();
     Filter = null;
     FetchStoredFields = false;
 }
 /// <summary>
 /// Wraps a Filter as a Query. The hits will get a constant score
 /// dependent on the boost factor of this query.
 /// If you simply want to strip off scores from a Query, no longer use
 /// {@code new ConstantScoreQuery(new QueryWrapperFilter(query))}, instead
 /// use <seealso cref="#ConstantScoreQuery(Query)"/>!
 /// </summary>
 public ConstantScoreQuery(Filter filter)
 {
     if (filter == null)
     {
         throw new System.NullReferenceException("Filter may not be null");
     }
     this.filter = filter;
     this.query = null;
 }
 public PKIndexSplitter(Directory input, Directory dir1, Directory dir2, Filter docsInFirstIndex, IndexWriterConfig config1, IndexWriterConfig config2)
 {
     this.input = input;
     this.dir1 = dir1;
     this.dir2 = dir2;
     this.docsInFirstIndex = docsInFirstIndex;
     this.config1 = config1;
     this.config2 = config2;
 }
Beispiel #15
0
		public /*internal*/ bool debugCheckedForDeletions = false; // for test purposes.
		
		internal Hits(Searcher s, Query q, Filter f)
		{
			weight = q.Weight(s);
			searcher = s;
			filter = f;
			nDeletions = CountDeletions(s);
			GetMoreDocs(50); // retrieve 100 initially
			lengthAtStart = length;
		}
 /// <summary>
 /// Strips off scores from the passed in Query. The hits will get a constant score
 /// dependent on the boost factor of this query.
 /// </summary>
 public ConstantScoreQuery(Query query)
 {
     if (query == null)
     {
         throw new System.NullReferenceException("Query may not be null");
     }
     this.filter = null;
     this.query = query;
 }
        /// <param name="strategy">Needed to compute intersects</param>
        /// <param name="args">Used in spatial intersection</param>
        /// <param name="field">
        /// This field is used to determine which docs have spatial data via
        /// <see cref="FieldCache.GetDocsWithField(AtomicReader, string)"/>.
        /// Passing null will assume all docs have spatial data.
        /// </param>
        public DisjointSpatialFilter(SpatialStrategy strategy, SpatialArgs args, string field)
        {
            this.field = field;

            // TODO consider making SpatialArgs cloneable
            SpatialOperation origOp = args.Operation; //copy so we can restore
            args.Operation = SpatialOperation.Intersects; //temporarily set to intersects
            intersectsFilter = strategy.MakeFilter(args);
            args.Operation = origOp;
        }
 private void TstFilterCard(String mes, int expected, Filter filt)
 {
     DocIdSetIterator disi = filt.GetDocIdSet(reader).Iterator();
     int actual = 0;
     while (disi.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
     {
         actual++;
     }
     Assert.AreEqual(expected, actual, mes);
 }
 public ValueSourceFilter(Filter startingFilter, ValueSource source, double min, double max)
 {
     if (startingFilter == null)
     {
         throw new ArgumentException("please provide a non-null startingFilter; you can use QueryWrapperFilter(MatchAllDocsQuery) as a no-op filter", "startingFilter");
     }
     this.startingFilter = startingFilter;
     this.source = source;
     this.min = min;
     this.max = max;
 }
 public LuceneQueryStatistics(Query query, Filter filter, Sort sort, TimeSpan elapsedPreparationTime, TimeSpan elapsedSearchTime, TimeSpan elapsedRetrievalTime, int totalHits, int skippedHits, int retrievedDocuments)
 {
     this.totalHits = totalHits;
     this.query = query;
     this.filter = filter;
     this.sort = sort;
     this.elapsedPreparationTime = elapsedPreparationTime;
     this.elapsedSearchTime = elapsedSearchTime;
     this.elapsedRetrievalTime = elapsedRetrievalTime;
     this.skippedHits = skippedHits;
     this.retrievedDocuments = retrievedDocuments;
 }
        public void End(IndexReader indexReader)
        {
            foreach (Tuple<NuGetVersion, string, int> entry in _lookup.Values)
            {
                string readerName = entry.Item2;
                int readerDocumentId = entry.Item3;

                _openBitSetLookup[readerName].Set(readerDocumentId);
            }

            Result = new OpenBitSetLookupFilter(_openBitSetLookup);
        }
 private void AssertFilterEquals(Filter f1, Filter f2)
 {
     Query query = new MatchAllDocsQuery();
     TopDocs hits1 = @is.Search(query, f1, Ir.MaxDoc());
     TopDocs hits2 = @is.Search(query, f2, Ir.MaxDoc());
     Assert.AreEqual(hits1.TotalHits, hits2.TotalHits);
     CheckHits.CheckEqual(query, hits1.ScoreDocs, hits2.ScoreDocs);
     // now do it again to confirm caching works
     TopDocs hits3 = @is.Search(query, f1, Ir.MaxDoc());
     TopDocs hits4 = @is.Search(query, f2, Ir.MaxDoc());
     Assert.AreEqual(hits3.TotalHits, hits4.TotalHits);
     CheckHits.CheckEqual(query, hits3.ScoreDocs, hits4.ScoreDocs);
 }
        public bool TryGetFilter(bool includeUnlisted, bool includePrerelease, string curatedFeed, out Filter filter)
        {
            Filter visibilityFilter = _latest[includeUnlisted ? 1 : 0][includePrerelease ? 1 : 0];

            Filter curatedFeedFilter;
            if (!string.IsNullOrEmpty(curatedFeed) && _curatedFeeds.TryGetValue(curatedFeed, out curatedFeedFilter))
            {
                filter = new ChainedFilter(new[] { visibilityFilter, curatedFeedFilter }, ChainedFilter.Logic.AND);
                return true;
            }

            filter = visibilityFilter;
            return true;
        }
Beispiel #24
0
 /// <summary>
 /// Expert: Constructs a new query which applies a filter to the results of the original query.
 /// <seealso cref="Filter#getDocIdSet"/> will be called every time this query is used in a search. </summary>
 /// <param name="query">  Query to be filtered, cannot be <code>null</code>. </param>
 /// <param name="filter"> Filter to apply to query results, cannot be <code>null</code>. </param>
 /// <param name="strategy"> a filter strategy used to create a filtered scorer.
 /// </param>
 /// <seealso cref= FilterStrategy </seealso>
 public FilteredQuery(Query query, Filter filter, FilterStrategy strategy)
 {
     if (query == null || filter == null)
     {
         throw new System.ArgumentException("Query and filter cannot be null.");
     }
     if (strategy == null)
     {
         throw new System.ArgumentException("FilterStrategy can not be null");
     }
     this.strategy = strategy;
     this.Query_Renamed = query;
     this.Filter_Renamed = filter;
 }
Beispiel #25
0
        public static Sort GetSort(this IndexQuery self, Filter filter, IndexDefinition indexDefinition)
        {
            var spatialIndexQuery = self as SpatialIndexQuery;
            if(spatialIndexQuery != null && spatialIndexQuery.SortByDistance)
            {
                var dsort = new Lucene.Net.Spatial.Tier.DistanceFieldComparatorSource((Lucene.Net.Spatial.Tier.DistanceFilter)filter);

                return new Sort(new SortField("foo", dsort, false));

            }

            if (self.SortedFields != null && self.SortedFields.Length > 0)
                return new Sort(self.SortedFields.Select(x => ToLuceneSortField(indexDefinition, x)).ToArray());
            return null;
        }
Beispiel #26
0
        /// <summary>
        /// Expert: by default, the cached filter will be shared
        /// across reopened segments that only had changes to their
        /// deletions.  
        /// </summary>
        /// <param name="filter">Filter to cache results of</param>
        /// <param name="deletesMode">See <see cref="DeletesMode" /></param>
        ///
        public CachingWrapperFilter(Filter filter, DeletesMode deletesMode)
        {
            this.filter = filter;
            cache = new AnonymousFilterCache(deletesMode);

            //cache = new FilterCache(deletesMode)
            // {
            //  public Object mergeDeletes(final IndexReader r, final Object docIdSet) {
            //    return new FilteredDocIdSet((DocIdSet) docIdSet) {
            //      protected boolean match(int docID) {
            //        return !r.isDeleted(docID);
            //      }
            //    };
            //  }
            //};
        }
 public override void SetUp()
 {
     Directory = NewDirectory();
     IndexWriterConfig config = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
     IndexWriter indexWriter = new IndexWriter(Directory, config);
     for (int i = 0; i < AMOUNT_OF_SEGMENTS; i++)
     {
         IList<Document> segmentDocs = CreateDocsForSegment(i);
         indexWriter.AddDocuments(segmentDocs);
         indexWriter.Commit();
     }
     IndexReader = DirectoryReader.Open(indexWriter, Random().NextBoolean());
     indexWriter.Dispose();
     IndexSearcher = new IndexSearcher(IndexReader);
     ParentsFilter = new FixedBitSetCachingWrapperFilter(new QueryWrapperFilter(new WildcardQuery(new Term("parent", "*"))));
 }
        /// <summary> A search implementation which spans a new thread for each
        /// Searchable, waits for each search to complete and merge
        /// the results back together.
        /// </summary>
        public override TopDocs Search(Weight weight, Filter filter, int nDocs)
        {
            HitQueue hq = new HitQueue(nDocs, false);
            int totalHits = 0;
            MultiSearcherThread[] msta = new MultiSearcherThread[searchables.Length];
            for (int i = 0; i < searchables.Length; i++)
            {
                // search each searchable
                // Assume not too many searchables and cost of creating a thread is by far inferior to a search
                msta[i] = new MultiSearcherThread(searchables[i], weight, filter, nDocs, hq, i, starts, "MultiSearcher thread #" + (i + 1));
                msta[i].Start();
            }

            for (int i = 0; i < searchables.Length; i++)
            {
                try
                {
                    msta[i].Join();
                }
                catch (System.Threading.ThreadInterruptedException ie)
                {
                    // In 3.0 we will change this to throw
                    // InterruptedException instead
                    SupportClass.ThreadClass.Current().Interrupt();
                    throw new System.SystemException(ie.Message, ie);
                }
                System.IO.IOException ioe = msta[i].GetIOException();
                if (ioe == null)
                {
                    totalHits += msta[i].Hits();
                }
                else
                {
                    // if one search produced an IOException, rethrow it
                    throw ioe;
                }
            }

            ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
            for (int i = hq.Size() - 1; i >= 0; i--)
            // put docs in array
                scoreDocs[i] = (ScoreDoc) hq.Pop();

            float maxScore = (totalHits == 0)?System.Single.NegativeInfinity:scoreDocs[0].score;

            return new TopDocs(totalHits, scoreDocs, maxScore);
        }
        public virtual void TestHugeN()
        {
            TaskScheduler service = new LimitedConcurrencyLevelTaskScheduler(4);

            IndexSearcher[] searchers = new IndexSearcher[] { new IndexSearcher(Reader), new IndexSearcher(Reader, service) };
            Query[] queries = new Query[] { new MatchAllDocsQuery(), new TermQuery(new Term("field", "1")) };
            Sort[] sorts = new Sort[] { null, new Sort(new SortField("field2", SortField.Type_e.STRING)) };
            Filter[] filters = new Filter[] { null, new QueryWrapperFilter(new TermQuery(new Term("field2", "true"))) };
            ScoreDoc[] afters = new ScoreDoc[] { null, new FieldDoc(0, 0f, new object[] { new BytesRef("boo!") }) };

            foreach (IndexSearcher searcher in searchers)
            {
                foreach (ScoreDoc after in afters)
                {
                    foreach (Query query in queries)
                    {
                        foreach (Sort sort in sorts)
                        {
                            foreach (Filter filter in filters)
                            {
                                searcher.Search(query, int.MaxValue);
                                searcher.SearchAfter(after, query, int.MaxValue);
                                searcher.Search(query, filter, int.MaxValue);
                                searcher.SearchAfter(after, query, filter, int.MaxValue);
                                if (sort != null)
                                {
                                    searcher.Search(query, int.MaxValue, sort);
                                    searcher.Search(query, filter, int.MaxValue, sort);
                                    searcher.Search(query, filter, int.MaxValue, sort, true, true);
                                    searcher.Search(query, filter, int.MaxValue, sort, true, false);
                                    searcher.Search(query, filter, int.MaxValue, sort, false, true);
                                    searcher.Search(query, filter, int.MaxValue, sort, false, false);
                                    searcher.SearchAfter(after, query, filter, int.MaxValue, sort);
                                    searcher.SearchAfter(after, query, filter, int.MaxValue, sort, true, true);
                                    searcher.SearchAfter(after, query, filter, int.MaxValue, sort, true, false);
                                    searcher.SearchAfter(after, query, filter, int.MaxValue, sort, false, true);
                                    searcher.SearchAfter(after, query, filter, int.MaxValue, sort, false, false);
                                }
                            }
                        }
                    }
                }
            }

            TestUtil.ShutdownExecutorService(service);
        }
Beispiel #30
0
        private QueryHelper <TModel> GeoFilter(Expression <Func <TModel, object> > exp, double longitude, double latitude, double distDEG)
        {
            string name = getName(exp.Body.ToString());
            //name = name.IndexOf('.') > -1 ? name.Substring(0, name.LastIndexOf('.')) : name;
            SpatialOperation op = SpatialOperation.Intersects;
            //SpatialStrategy strat = new PointVectorStrategy(ctx, name);
            int maxLevels          = 11;
            SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
            var strat = new RecursivePrefixTreeStrategy(grid, name);

            var point = ctx.MakePoint(longitude, latitude);
            var shape = ctx.MakeCircle(point, distDEG);
            var args  = new SpatialArgs(op, shape);

            filter = strat.MakeFilter(args);
            return(this);
        }
Beispiel #31
0
        public SearchResult GetSearchResult(Query query, Filter filter, int skip, int take, Sort sort)
        {
            var s            = Stopwatch.StartNew();
            var searchResult = _luceneSearcher.Search(query, filter, skip + take, sort);

            s.Stop();
            return(new SearchResult
            {
                Links = searchResult.ScoreDocs
                        .Skip(skip)
                        .Take(take)
                        .Select(storeDoc => new SearchResultItem {
                    Link = _luceneSearcher.Doc(storeDoc.Doc).GetField(SearchSettings.Field_ID).StringValue, Score = storeDoc.Score
                })
                        .ToArray(),
                Total = searchResult.TotalHits,
                ElapsedMilliseconds = (int)s.ElapsedMilliseconds
            });
        }
Beispiel #32
0
		protected DistanceFilter(Filter startingFilter, double distance)
		{
			if (startingFilter == null)
			{
				throw new ArgumentNullException("startingFilter", "Please provide a non-null startingFilter; you can use QueryWrapperFilter(MatchAllDocsQuery) as a no-op filter");
			}

			StartingFilter = startingFilter;
			Distance = distance;

			// NOTE: neither of the distance filters use precision
			// now - if we turn that on, we'll need to pass top
			// reader into here
			// setPrecision(reader.maxDoc());

			/* store calculated distances for reuse by other components */
			Distances = new Dictionary<int, Double>();

			// create an intermediate cache to avoid recomputing distances for the same point 
			DistanceLookupCache = new Dictionary<string, double>();
		}
 public IFullTextQuery SetFilter(Lucene.Net.Search.Filter value)
 {
     this.filter = value;
     return(this);
 }
 /// <param name="filter">Filter to cache results of
 /// </param>
 public CachingWrapperFilter(Filter filter)
 {
     this.filter = filter;
 }
Beispiel #35
0
        protected override Query GetFieldQuery(string field, string queryText, bool quoted)
        {
            try
            {
                if ((field == "PuckGeoK" && !PuckCache.TypeFields[TypeName].ContainsKey("PuckGeoK")) || (field == "PuckGeoM" && !PuckCache.TypeFields[TypeName].ContainsKey("PuckGeoM")))
                {
                    var    parameters = queryText.Split(',', StringSplitOptions.RemoveEmptyEntries);
                    double longitude;
                    double latitude;
                    int    distance;
                    if (parameters.Length == 5 && double.TryParse(parameters[1].Trim(), out longitude) && double.TryParse(parameters[2].Trim(), out latitude) && int.TryParse(parameters[3].Trim(), out distance))
                    {
                        var    qh = new QueryHelper <T>();
                        double radius;

                        if (field == "PuckGeoK")
                        {
                            radius = DistanceUtils.EARTH_MEAN_RADIUS_KM;
                        }
                        else
                        {
                            radius = DistanceUtils.EARTH_MEAN_RADIUS_MI;
                        }

                        var distDEG = DistanceUtils.Dist2Degrees(distance, radius);
                        qh.GeoFilter(parameters[0].Trim(), longitude, latitude, distance);
                        this.filter = qh.GetFilter();
                        if (parameters[4] == "asc")
                        {
                            qh.SortByDistanceFromPoint(parameters[0].Trim(), longitude, latitude, desc: false);
                            sort = qh.GetSort();
                        }
                        else if (parameters[4] == "desc")
                        {
                            qh.SortByDistanceFromPoint(parameters[0].Trim(), longitude, latitude, desc: true);
                            sort = qh.GetSort();
                        }
                    }
                }
                else
                {
                    Type fieldType = null;
                    if (FieldTypeMappings != null)
                    {
                        if (FieldTypeMappings.TryGetValue(field, out fieldType))
                        {
                        }
                        else
                        {
                            PuckCache.TypeFields[TypeName]?.TryGetValue(field, out fieldType);
                        }
                    }
                    else
                    {
                        PuckCache.TypeFields[TypeName]?.TryGetValue(field, out fieldType);
                    }
                    if (fieldType != null)
                    {
                        if (fieldType.Equals(typeof(int)) || fieldType.Equals(typeof(int?)))
                        {
                            BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT32);
                            NumericUtils.Int32ToPrefixCoded(int.Parse(queryText), 0, bytes);
                            return(new TermQuery(new Term(field, bytes)));
                        }
                        else if (fieldType.Equals(typeof(long)) || fieldType.Equals(typeof(long?)))
                        {
                            BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT64);
                            NumericUtils.Int64ToPrefixCoded(long.Parse(queryText), 0, bytes);
                            return(new TermQuery(new Term(field, bytes)));
                        }
                        else if (fieldType.Equals(typeof(float)) || fieldType.Equals(typeof(float?)))
                        {
                            BytesRef bytes    = new BytesRef(NumericUtils.BUF_SIZE_INT32);
                            int      intFloat = NumericUtils.SingleToSortableInt32(float.Parse(queryText));
                            NumericUtils.Int32ToPrefixCoded(intFloat, 0, bytes);
                            return(new TermQuery(new Term(field, bytes)));
                        }
                        else if (fieldType.Equals(typeof(double)) || fieldType.Equals(typeof(double?)))
                        {
                            BytesRef bytes      = new BytesRef(NumericUtils.BUF_SIZE_INT64);
                            long     longDouble = NumericUtils.DoubleToSortableInt64(double.Parse(queryText));
                            NumericUtils.Int64ToPrefixCoded(longDouble, 0, bytes);
                            return(new TermQuery(new Term(field, bytes)));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(base.GetFieldQuery(field, queryText, quoted));
        }