org.apache.lucene.search.FieldCache Java Examples

The following examples show how to use org.apache.lucene.search.FieldCache. 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: XJoinValueSourceParser.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("rawtypes")
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
  final BinaryDocValues joinValues = FieldCache.DEFAULT.getTerms(readerContext.reader(), joinField, false);

  return new DoubleDocValues(this) {

    @Override
    public double doubleVal(int doc) {
      BytesRef joinValue = joinValues.get(doc);
      if (joinValue == null) {
        throw new RuntimeException("No such doc: " + doc);
      }
      Object result = results.getResult(joinValue.utf8ToString());
      if (result == null) {
        return defaultValue;
      }
      if (result instanceof Iterable) {
        Double max = null;
        for (Object object : (Iterable)result) {
          if (object != null) {
            double value = getValue(object);
            if (max == null || value > max) {
              max = value;
            }
          }
        }
        return max != null ? max : defaultValue;
      } else {
        return getValue(result);
      }
    }
    
  };
}
 
Example #2
Source File: QueryAutoFilteringComponent.java    From query-autofiltering-component with Apache License 2.0 5 votes vote down vote up
private void buildFieldMap( ResponseBuilder rb ) throws IOException {
  Log.debug( "buildFieldMap" );
  SolrIndexSearcher searcher = rb.req.getSearcher();
  // build a synonym map from the SortedDocValues -
  // for each field value: lower case, stemmed, lookup synonyms from synonyms.txt - map to fieldValue
  SynonymMap.Builder fieldBuilder = new SynonymMap.Builder( true );
  SynonymMap.Builder termBuilder = new SynonymMap.Builder( true );
    
  ArrayList<String> searchFields = getStringFields( searcher );

  for (String searchField : searchFields ) {
    Log.debug( "adding searchField " + searchField );
    CharsRef fieldChars = new CharsRef( searchField );
    SortedSetDocValues sdv = FieldCache.DEFAULT.getDocTermOrds( searcher.getAtomicReader( ), searchField );
    if (sdv == null) continue;
    Log.debug( "got SortedSetDocValues for " + searchField );
    TermsEnum te = sdv.termsEnum();
    while (te.next() != null) {
      BytesRef term = te.term();
      String fieldValue = term.utf8ToString( );
      addTerm ( fieldChars, fieldValue, fieldBuilder, termBuilder );
    }
  }
    
  addDistributedTerms( rb, fieldBuilder, termBuilder, searchFields );
    
  fieldMap = fieldBuilder.build( );
  termMap = termBuilder.build( );
}
 
Example #3
Source File: LindenUtil.java    From linden with Apache License 2.0 5 votes vote down vote up
private static boolean actualContain(AtomicReader reader, String field, int locDocId) {
  try {
    // index really contains such field of this doc
    return FieldCache.DEFAULT.getDocsWithField(reader, field).get(locDocId);
  } catch (IOException e) {
    return false;
  }
}
 
Example #4
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public SortedDocValues getTermsIndex(AtomicReader reader, String field) throws IOException {
  return FieldCache.DEFAULT.getTermsIndex(reader, field);
}
 
Example #5
Source File: LindenUtil.java    From linden with Apache License 2.0 4 votes vote down vote up
public static Integer getFieldIntValue(List<AtomicReaderContext> leaves, int docId, String fieldName)
    throws IOException {
  AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
  FieldCache.Ints ints = FieldCache.DEFAULT.getInts(atomicReaderContext.reader(), fieldName, false);
  return ints.get(docId - atomicReaderContext.docBase);
}
 
Example #6
Source File: LindenUtil.java    From linden with Apache License 2.0 4 votes vote down vote up
public static Long getFieldLongValue(List<AtomicReaderContext> leaves, int docId, String fieldName)
    throws IOException {
  AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
  FieldCache.Longs longs = FieldCache.DEFAULT.getLongs(atomicReaderContext.reader(), fieldName, false);
  return longs.get(docId - atomicReaderContext.docBase);
}
 
Example #7
Source File: LindenUtil.java    From linden with Apache License 2.0 4 votes vote down vote up
public static String getFieldStringValue(List<AtomicReaderContext> leaves, int docId, String fieldName)
    throws IOException {
  AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
  BinaryDocValues terms = FieldCache.DEFAULT.getTerms(atomicReaderContext.reader(), fieldName, false);
  return terms.get(docId - atomicReaderContext.docBase).utf8ToString();
}
 
Example #8
Source File: LindenUtil.java    From linden with Apache License 2.0 4 votes vote down vote up
public static Double getFieldDoubleValue(List<AtomicReaderContext> leaves, int docId, String fieldName)
    throws IOException {
  AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
  FieldCache.Doubles doubles = FieldCache.DEFAULT.getDoubles(atomicReaderContext.reader(), fieldName, false);
  return doubles.get(docId - atomicReaderContext.docBase);
}
 
Example #9
Source File: LindenUtil.java    From linden with Apache License 2.0 4 votes vote down vote up
public static Float getFieldFloatValue(List<AtomicReaderContext> leaves, int docId, String fieldName)
    throws IOException {
  AtomicReaderContext atomicReaderContext = leaves.get(ReaderUtil.subIndex(docId, leaves));
  FieldCache.Floats floats = FieldCache.DEFAULT.getFloats(atomicReaderContext.reader(), fieldName, false);
  return floats.get(docId - atomicReaderContext.docBase);
}
 
Example #10
Source File: LindenScoreModelStrategy.java    From linden with Apache License 2.0 4 votes vote down vote up
public IndexedStringsWrapper(String field, AtomicReader reader) throws IOException {
  values = FieldCache.DEFAULT.getTerms(reader, field, false);
}
 
Example #11
Source File: LindenScoreModelStrategy.java    From linden with Apache License 2.0 4 votes vote down vote up
public FloatsWrapper(String field, AtomicReader reader) throws IOException {
  floats = FieldCache.DEFAULT.getFloats(reader, field, false);
}
 
Example #12
Source File: LindenScoreModelStrategy.java    From linden with Apache License 2.0 4 votes vote down vote up
public DoublesWrapper(String field, AtomicReader reader) throws IOException {
  doubles = FieldCache.DEFAULT.getDoubles(reader, field, false);
}
 
Example #13
Source File: LindenScoreModelStrategy.java    From linden with Apache License 2.0 4 votes vote down vote up
public LongsWrapper(String field, AtomicReader reader) throws IOException {
  longs = FieldCache.DEFAULT.getLongs(reader, field, false);
}
 
Example #14
Source File: LindenScoreModelStrategy.java    From linden with Apache License 2.0 4 votes vote down vote up
public IntsWrapper(String field, AtomicReader reader) throws IOException {
  ints = FieldCache.DEFAULT.getInts(reader, field, false);
}
 
Example #15
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public SortedSetDocValues getDocTermOrds(AtomicReader reader, String field) throws IOException {
  return FieldCache.DEFAULT.getDocTermOrds(reader, field);
}
 
Example #16
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public SortedDocValues getTermsIndex(AtomicReader reader, String field, float acceptableOverheadRatio)
    throws IOException {
  return FieldCache.DEFAULT.getTermsIndex(reader, field, acceptableOverheadRatio);
}
 
Example #17
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Bits getDocsWithField(AtomicReader reader, String field) throws IOException {
  return FieldCache.DEFAULT.getDocsWithField(reader, field);
}
 
Example #18
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public BinaryDocValues getTerms(AtomicReader reader, String field, boolean setDocsWithField,
                                float acceptableOverheadRatio) throws IOException {
  return FieldCache.DEFAULT.getTerms(reader, field, setDocsWithField, acceptableOverheadRatio);
}
 
Example #19
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public BinaryDocValues getTerms(AtomicReader reader, String field, boolean setDocsWithField) throws IOException {
  return FieldCache.DEFAULT.getTerms(reader, field, setDocsWithField);
}
 
Example #20
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Doubles getDoubles(AtomicReader reader, String field, DoubleParser parser, boolean setDocsWithField)
    throws IOException {
  return FieldCache.DEFAULT.getDoubles(reader, field, parser, setDocsWithField);
}
 
Example #21
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Doubles getDoubles(AtomicReader reader, String field, boolean setDocsWithField) throws IOException {
  return FieldCache.DEFAULT.getDoubles(reader, field, setDocsWithField);
}
 
Example #22
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Longs getLongs(AtomicReader reader, String field, LongParser parser, boolean setDocsWithField)
    throws IOException {
  return FieldCache.DEFAULT.getLongs(reader, field, parser, setDocsWithField);
}
 
Example #23
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Longs getLongs(AtomicReader reader, String field, boolean setDocsWithField) throws IOException {
  return FieldCache.DEFAULT.getLongs(reader, field, setDocsWithField);
}
 
Example #24
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Floats getFloats(AtomicReader reader, String field, FloatParser parser, boolean setDocsWithField)
    throws IOException {
  return FieldCache.DEFAULT.getFloats(reader, field, parser, setDocsWithField);
}
 
Example #25
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Floats getFloats(AtomicReader reader, String field, boolean setDocsWithField) throws IOException {
  return FieldCache.DEFAULT.getFloats(reader, field, setDocsWithField);
}
 
Example #26
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Ints getInts(AtomicReader reader, String field, IntParser parser, boolean setDocsWithField)
    throws IOException {
  return FieldCache.DEFAULT.getInts(reader, field, parser, setDocsWithField);
}
 
Example #27
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Ints getInts(AtomicReader reader, String field, boolean setDocsWithField) throws IOException {
  return FieldCache.DEFAULT.getInts(reader, field, setDocsWithField);
}
 
Example #28
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Shorts getShorts(AtomicReader reader, String field, ShortParser parser, boolean setDocsWithField)
    throws IOException {
  return FieldCache.DEFAULT.getShorts(reader, field, parser, setDocsWithField);
}
 
Example #29
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Shorts getShorts(AtomicReader reader, String field, boolean setDocsWithField) throws IOException {
  return FieldCache.DEFAULT.getShorts(reader, field, setDocsWithField);
}
 
Example #30
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
public Bytes getBytes(AtomicReader reader, String field, ByteParser parser, boolean setDocsWithField)
    throws IOException {
  return FieldCache.DEFAULT.getBytes(reader, field, parser, setDocsWithField);
}