org.apache.lucene.index.ImpactsEnum Java Examples
The following examples show how to use
org.apache.lucene.index.ImpactsEnum.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Lucene84PostingsReader.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public ImpactsEnum impacts(FieldInfo fieldInfo, BlockTermState state, int flags) throws IOException { if (state.docFreq <= BLOCK_SIZE) { // no skip data return new SlowImpactsEnum(postings(fieldInfo, state, null, flags)); } final boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0; final boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0; final boolean indexHasPayloads = fieldInfo.hasPayloads(); if (indexHasPositions == false || PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) == false) { return new BlockImpactsDocsEnum(fieldInfo, (IntBlockTermState) state); } if (indexHasPositions && PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) && (indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) && (indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) { return new BlockImpactsPostingsEnum(fieldInfo, (IntBlockTermState) state); } return new BlockImpactsEverythingEnum(fieldInfo, (IntBlockTermState) state, flags); }
Example #2
Source File: PhraseQuery.java From lucene-solr with Apache License 2.0 | 6 votes |
public PostingsAndFreq(PostingsEnum postings, ImpactsEnum impacts, int position, Term... terms) { this.postings = postings; this.impacts = impacts; this.position = position; nTerms = terms==null ? 0 : terms.length; if (nTerms>0) { if (terms.length==1) { this.terms = terms; } else { Term[] terms2 = new Term[terms.length]; System.arraycopy(terms, 0, terms2, 0, terms.length); Arrays.sort(terms2); this.terms = terms2; } } else { this.terms = null; } }
Example #3
Source File: Lucene50PostingsReader.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public ImpactsEnum impacts(FieldInfo fieldInfo, BlockTermState state, int flags) throws IOException { if (state.docFreq <= BLOCK_SIZE || version < Lucene50PostingsFormat.VERSION_IMPACT_SKIP_DATA) { // no skip data return new SlowImpactsEnum(postings(fieldInfo, state, null, flags)); } final boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0; final boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0; final boolean indexHasPayloads = fieldInfo.hasPayloads(); if (indexHasPositions && PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) && (indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) && (indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) { return new BlockImpactsPostingsEnum(fieldInfo, (IntBlockTermState) state); } return new BlockImpactsEverythingEnum(fieldInfo, (IntBlockTermState) state, flags); }
Example #4
Source File: ExactPhraseMatcher.java From lucene-solr with Apache License 2.0 | 6 votes |
ExactPhraseMatcher(PhraseQuery.PostingsAndFreq[] postings, ScoreMode scoreMode, SimScorer scorer, float matchCost) { super(matchCost); final DocIdSetIterator approximation = ConjunctionDISI.intersectIterators(Arrays.stream(postings).map(p -> p.postings).collect(Collectors.toList())); final ImpactsSource impactsSource = mergeImpacts(Arrays.stream(postings).map(p -> p.impacts).toArray(ImpactsEnum[]::new)); if (scoreMode == ScoreMode.TOP_SCORES) { this.approximation = this.impactsApproximation = new ImpactsDISI(approximation, impactsSource, scorer); } else { this.approximation = approximation; this.impactsApproximation = new ImpactsDISI(approximation, impactsSource, scorer); } List<PostingsAndPosition> postingsAndPositions = new ArrayList<>(); for(PhraseQuery.PostingsAndFreq posting : postings) { postingsAndPositions.add(new PostingsAndPosition(posting.postings, posting.position)); } this.postings = postingsAndPositions.toArray(new PostingsAndPosition[postingsAndPositions.size()]); }
Example #5
Source File: TermScorer.java From querqy with Apache License 2.0 | 5 votes |
/** * Construct a {@link org.apache.lucene.search.TermScorer} that will use impacts to skip blocks of * non-competitive documents. */ TermScorer(Weight weight, ImpactsEnum impactsEnum, LeafSimScorer docScorer) { super(weight); postingsEnum = this.impactsEnum = impactsEnum; impactsDisi = new ImpactsDISI(impactsEnum, impactsEnum, docScorer.getSimScorer()); iterator = impactsDisi; this.docScorer = docScorer; }
Example #6
Source File: SegmentTermsEnum.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { assert !eof; //if (DEBUG) { //System.out.println("BTTR.docs seg=" + segment); //} currentFrame.decodeMetaData(); //if (DEBUG) { //System.out.println(" state=" + currentFrame.state); //} return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.state, flags); }
Example #7
Source File: TermScorer.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Construct a {@link TermScorer} that will use impacts to skip blocks of * non-competitive documents. */ TermScorer(Weight weight, ImpactsEnum impactsEnum, LeafSimScorer docScorer) { super(weight); postingsEnum = this.impactsEnum = impactsEnum; impactsDisi = new ImpactsDISI(impactsEnum, impactsEnum, docScorer.getSimScorer()); iterator = impactsDisi; this.docScorer = docScorer; }
Example #8
Source File: PhraseQuery.java From lucene-solr with Apache License 2.0 | 5 votes |
public PostingsAndFreq(PostingsEnum postings, ImpactsEnum impacts, int position, List<Term> terms) { this.postings = postings; this.impacts = impacts; this.position = position; nTerms = terms == null ? 0 : terms.size(); if (nTerms > 0) { Term[] terms2 = terms.toArray(new Term[0]); if (nTerms > 1) { Arrays.sort(terms2); } this.terms = terms2; } else { this.terms = null; } }
Example #9
Source File: OrdsSegmentTermsEnum.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { assert !eof; //if (DEBUG) { //System.out.println("BTTR.docs seg=" + segment); //} currentFrame.decodeMetaData(); //if (DEBUG) { //System.out.println(" state=" + currentFrame.state); //} return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.state, flags); }
Example #10
Source File: FuzzyTermsEnum.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return actualEnum.impacts(flags); }
Example #11
Source File: TestSynonymQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
public void testMergeImpacts() throws IOException { DummyImpactsEnum impacts1 = new DummyImpactsEnum(); impacts1.reset(42, new Impact[][] { new Impact[] { new Impact(3, 10), new Impact(5, 12), new Impact(8, 13) }, new Impact[] { new Impact(5, 11), new Impact(8, 13), new Impact(12, 14) } }, new int[] { 110, 945 }); DummyImpactsEnum impacts2 = new DummyImpactsEnum(); impacts2.reset(45, new Impact[][] { new Impact[] { new Impact(2, 10), new Impact(6, 13) }, new Impact[] { new Impact(3, 9), new Impact(5, 11), new Impact(7, 13) } }, new int[] { 90, 1000 }); ImpactsSource mergedImpacts = SynonymQuery.mergeImpacts(new ImpactsEnum[] { impacts1, impacts2 }, new float[] { 1f, 1f }); assertEquals( new Impact[][] { new Impact[] { new Impact(5, 10), new Impact(7, 12), new Impact(14, 13) }, new Impact[] { new Impact(Integer.MAX_VALUE, 1) } }, new int[] { 90, 1000 }, mergedImpacts.getImpacts()); ImpactsSource mergedBoostedImpacts = SynonymQuery.mergeImpacts(new ImpactsEnum[] { impacts1, impacts2 }, new float[] { 0.3f, 0.9f }); assertEquals( new Impact[][] { new Impact[] { new Impact(3, 10), new Impact(4, 12), new Impact(9, 13) }, new Impact[] { new Impact(Integer.MAX_VALUE, 1) } }, new int[] { 90, 1000 }, mergedBoostedImpacts.getImpacts()); // docID is > the first doIdUpTo of impacts1 impacts2.reset(112, new Impact[][] { new Impact[] { new Impact(2, 10), new Impact(6, 13) }, new Impact[] { new Impact(3, 9), new Impact(5, 11), new Impact(7, 13) } }, new int[] { 150, 1000 }); assertEquals( new Impact[][] { new Impact[] { new Impact(3, 10), new Impact(5, 12), new Impact(8, 13) }, // same as impacts1 new Impact[] { new Impact(3, 9), new Impact(10, 11), new Impact(15, 13), new Impact(19, 14) } }, new int[] { 110, 945 }, mergedImpacts.getImpacts()); assertEquals( new Impact[][] { new Impact[] { new Impact(1, 10), new Impact(2, 12), new Impact(3, 13) }, // same as impacts1*boost new Impact[] { new Impact(3, 9), new Impact(7, 11), new Impact(10, 13), new Impact(11, 14) } }, new int[] { 110, 945 }, mergedBoostedImpacts.getImpacts()); }
Example #12
Source File: DocTermOrds.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return termsEnum.impacts(flags); }
Example #13
Source File: SolrRangeQuery.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return te.impacts(flags); }
Example #14
Source File: CompressingTermVectorsReader.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { final PostingsEnum delegate = postings(null, PostingsEnum.FREQS); return new SlowImpactsEnum(delegate); }
Example #15
Source File: IntersectTermsEnum.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { currentFrame.decodeMetaData(); return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.termState, flags); }
Example #16
Source File: FSTTermsReader.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { decodeMetaData(); return postingsReader.impacts(fieldInfo, state, flags); }
Example #17
Source File: Lucene80DocValuesProducer.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { throw new UnsupportedOperationException(); }
Example #18
Source File: DocValuesConsumer.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { throw new UnsupportedOperationException(); }
Example #19
Source File: RAMOnlyPostingsFormat.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return new SlowImpactsEnum(postings(null, PostingsEnum.FREQS)); }
Example #20
Source File: IDVersionPostingsReader.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(FieldInfo fieldInfo, BlockTermState state, int flags) throws IOException { throw new UnsupportedOperationException("Should never be called, IDVersionSegmentTermsEnum implements impacts directly"); }
Example #21
Source File: IDVersionSegmentTermsEnum.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { // Only one posting, the slow impl is fine // We could make this throw UOE but then CheckIndex is angry return new SlowImpactsEnum(postings(null, flags)); }
Example #22
Source File: STMergingTermsEnum.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) { throw new UnsupportedOperationException(); }
Example #23
Source File: BlockReader.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { readTermStateIfNotRead(); return postingsReader.impacts(fieldMetadata.getFieldInfo(), termState, flags); }
Example #24
Source File: BloomFilteringPostingsFormat.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return delegate().impacts(flags); }
Example #25
Source File: SimpleTextFieldsReader.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return new SlowImpactsEnum(postings(null, flags)); }
Example #26
Source File: SimpleTextTermVectorsReader.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return new SlowImpactsEnum(postings(null, PostingsEnum.FREQS)); }
Example #27
Source File: BlockTermsReader.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { decodeMetaData(); return postingsReader.impacts(fieldInfo, state, flags); }
Example #28
Source File: OrdsIntersectTermsEnum.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { currentFrame.decodeMetaData(); return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.termState, flags); }
Example #29
Source File: DirectPostingsFormat.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return new SlowImpactsEnum(postings(null, flags)); }
Example #30
Source File: DirectPostingsFormat.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ImpactsEnum impacts(int flags) throws IOException { return new SlowImpactsEnum(postings(null, flags)); }