Java Code Examples for org.apache.lucene.search.FieldCache

The following examples show how to use org.apache.lucene.search.FieldCache. These examples are extracted from open source projects. 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 Project: linden   Source File: LindenUtil.java    License: 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 2
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 Project: BioSolr   Source File: XJoinValueSourceParser.java    License: 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 4
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 5
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Bytes getBytes(AtomicReader reader, String field, boolean setDocsWithField) throws IOException {
  return FieldCache.DEFAULT.getBytes(reader, field, setDocsWithField);
}
 
Example 6
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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);
}
 
Example 7
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 8
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 9
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 10
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 11
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 12
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 13
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 14
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 15
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 16
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 17
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 18
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 20
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 21
Source Project: linden   Source File: LindenFieldCacheImpl.java    License: 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 22
Source Project: linden   Source File: LindenScoreModelStrategy.java    License: 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 23
Source Project: linden   Source File: LindenScoreModelStrategy.java    License: 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 24
Source Project: linden   Source File: LindenScoreModelStrategy.java    License: 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 25
Source Project: linden   Source File: LindenScoreModelStrategy.java    License: 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 26
Source Project: linden   Source File: LindenScoreModelStrategy.java    License: 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 27
Source Project: linden   Source File: LindenUtil.java    License: 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 28
Source Project: linden   Source File: LindenUtil.java    License: 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 29
Source Project: linden   Source File: LindenUtil.java    License: 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 30
Source Project: linden   Source File: LindenUtil.java    License: 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);
}