Example #1
0
        private ICollection <EntityId> InternalQuery(Query query, QueryContext contextOrNull)
        {
            if (this._directory == null)
            {
                return(Collections.emptySet());
            }

            try
            {
                Sort          sorting = contextOrNull != null ? contextOrNull.Sorting : null;
                bool          prioritizeCorrectness = contextOrNull == null || !contextOrNull.TradeCorrectnessForSpeed;
                IndexSearcher theSearcher           = Searcher(prioritizeCorrectness);
                query = IncludeOrphans(query);
                DocValuesCollector docValuesCollector = new DocValuesCollector(prioritizeCorrectness);
                theSearcher.search(query, docValuesCollector);
                ICollection <EntityId> result = new List <EntityId>();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator valuesIterator = docValuesCollector.getSortedValuesIterator(KEY_DOC_ID, sorting);
                LongIterator valuesIterator = docValuesCollector.GetSortedValuesIterator(KEY_DOC_ID, sorting);
                while (valuesIterator.hasNext())
                {
                    result.Add(new EntityId_IdData(valuesIterator.next()));
                }
                return(result);
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
        }
Example #2
0
 private DocValuesCollector Search(Query query)
 {
     try
     {
         DocValuesCollector docValuesCollector = new DocValuesCollector();
         IndexSearcher.search(query, docValuesCollector);
         return(docValuesCollector);
     }
     catch (IOException e)
     {
         throw new Exception(e);
     }
 }
 private ScoreEntityIterator IndexQuery(Query query)
 {
     try
     {
         DocValuesCollector docValuesCollector = new DocValuesCollector(true);
         IndexSearcher.search(query, docValuesCollector);
         ValuesIterator sortedValuesIterator = docValuesCollector.GetSortedValuesIterator(LuceneFulltextDocumentStructure.FIELD_ENTITY_ID, Sort.RELEVANCE);
         return(new ScoreEntityIterator(sortedValuesIterator));
     }
     catch (IOException e)
     {
         throw new Exception(e);
     }
 }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.eclipse.collections.api.set.primitive.LongSet gatherIdsModifiedInTransactionState(java.util.List<EntityId> simpleTransactionStateIds, org.apache.lucene.search.IndexSearcher fulltextTransactionStateSearcher, org.apache.lucene.search.Query query) throws java.io.IOException
        private LongSet GatherIdsModifiedInTransactionState(IList <EntityId> simpleTransactionStateIds, IndexSearcher fulltextTransactionStateSearcher, Query query)
        {
            // If there's no state them don't bother gathering it
            if (simpleTransactionStateIds.Count == 0 && fulltextTransactionStateSearcher == null)
            {
                return(LongSets.immutable.empty());
            }
            // There's potentially some state
            DocValuesCollector docValuesCollector = null;
            int fulltextSize = 0;

            if (fulltextTransactionStateSearcher != null)
            {
                docValuesCollector = new DocValuesCollector();
                fulltextTransactionStateSearcher.search(query, docValuesCollector);
                fulltextSize = docValuesCollector.TotalHits;
                // Nah, no state
                if (simpleTransactionStateIds.Count == 0 && fulltextSize == 0)
                {
                    return(LongSets.immutable.empty());
                }
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet set = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(simpleTransactionStateIds.size() + fulltextSize);
            MutableLongSet set = new LongHashSet(simpleTransactionStateIds.Count + fulltextSize);

            // Add from simple tx state
            foreach (EntityId id in simpleTransactionStateIds)
            {
                set.add(id.Id());
            }

            if (docValuesCollector != null)
            {
                // Add from fulltext tx state
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator valuesIterator = docValuesCollector.getValuesIterator(LuceneExplicitIndex.KEY_DOC_ID);
                LongIterator valuesIterator = docValuesCollector.GetValuesIterator(LuceneExplicitIndex.KEY_DOC_ID);
                while (valuesIterator.hasNext())
                {
                    set.add(valuesIterator.next());
                }
            }
            return(set);
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private org.neo4j.graphdb.index.IndexHits<long> query(org.apache.lucene.search.Query query, final String key, final Object value)
        private IndexHits <long> Query(Query query, string key, object value)
        {
            IndexSearcher searcher;

            try
            {
                searcher = _searcherManager.acquire();
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
            try
            {
                DocValuesCollector collector = new DocValuesCollector(true);
                searcher.search(query, collector);
                IndexHits <Document> result        = collector.GetIndexHits(Sort.RELEVANCE);
                ExplicitIndexHits    primitiveHits = null;
                if (string.ReferenceEquals(key, null) || this._cache == null || !this._cache.ContainsKey(key))
                {
                    primitiveHits = new DocToIdIterator(result, Collections.emptyList(), null, LongSets.immutable.empty());
                }
                else
                {
                    primitiveHits = new DocToIdIteratorAnonymousInnerClass(this, result, Collections.emptyList(), LongSets.immutable.empty(), key, value);
                }
                return(WrapIndexHits(primitiveHits));
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
            finally
            {
                try
                {
                    _searcherManager.release(searcher);
                }
                catch (IOException)
                {
                }
            }
        }
Example #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void letThroughAdditions(org.apache.lucene.search.IndexSearcher additionsSearcher, org.apache.lucene.search.Query query, java.util.Collection<EntityId> removed) throws java.io.IOException
        private void LetThroughAdditions(IndexSearcher additionsSearcher, Query query, ICollection <EntityId> removed)
        {
            // This could be improved further by doing a term-dict lookup for every term in removed
            // and retaining only those that did not match.
            // This is getting quite low-level though
            DocValuesCollector collector = new DocValuesCollector(false);

            additionsSearcher.search(query, collector);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.iterator.LongIterator valuesIterator = collector.getValuesIterator(KEY_DOC_ID);
            LongIterator valuesIterator = collector.GetValuesIterator(KEY_DOC_ID);
            LongCostume  id             = new LongCostume();

            while (valuesIterator.hasNext())
            {
                long value = valuesIterator.next();
                removed.remove(id.setId(value));
            }
        }
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.graphdb.index.IndexHits<org.apache.lucene.document.Document> search(IndexReference searcherRef, org.apache.lucene.search.IndexSearcher fulltextTransactionStateSearcher, org.apache.lucene.search.Query query, org.neo4j.index.lucene.QueryContext additionalParametersOrNull, java.util.Collection<EntityId> removed) throws java.io.IOException
        private IndexHits <Document> Search(IndexReference searcherRef, IndexSearcher fulltextTransactionStateSearcher, Query query, QueryContext additionalParametersOrNull, ICollection <EntityId> removed)
        {
            if (fulltextTransactionStateSearcher != null && removed.Count > 0)
            {
                LetThroughAdditions(fulltextTransactionStateSearcher, query, removed);
            }

            IndexSearcher        searcher = fulltextTransactionStateSearcher == null ? searcherRef.Searcher : new IndexSearcher(new MultiReader(searcherRef.Searcher.IndexReader, fulltextTransactionStateSearcher.IndexReader));
            IndexHits <Document> result;

            if (additionalParametersOrNull != null && additionalParametersOrNull.Top > 0)
            {
                result = new TopDocsIterator(query, additionalParametersOrNull, searcher);
            }
            else
            {
                Sort sorting    = additionalParametersOrNull != null ? additionalParametersOrNull.Sorting : null;
                bool forceScore = additionalParametersOrNull == null || !additionalParametersOrNull.TradeCorrectnessForSpeed;
                DocValuesCollector collector = new DocValuesCollector(forceScore);
                searcher.search(query, collector);
                return(collector.GetIndexHits(sorting));
            }
            return(result);
        }