Java 类org.apache.lucene.index.FieldInvertState 实例源码

项目:search    文件:MemoryIndex.java   
@Override
public NumericDocValues getNormValues(String field) {
  FieldInfo fieldInfo = fieldInfos.get(field);
  if (fieldInfo == null || fieldInfo.omitsNorms())
    return null;
  NumericDocValues norms = cachedNormValues;
  Similarity sim = getSimilarity();
  if (!field.equals(cachedFieldName) || sim != cachedSimilarity) { // not cached?
    Info info = getInfo(field);
    int numTokens = info != null ? info.numTokens : 0;
    int numOverlapTokens = info != null ? info.numOverlapTokens : 0;
    float boost = info != null ? info.getBoost() : 1.0f; 
    FieldInvertState invertState = new FieldInvertState(field, 0, numTokens, numOverlapTokens, 0, boost);
    long value = sim.computeNorm(invertState);
    norms = new MemoryIndexNormDocValues(value);
    // cache it for future reuse
    cachedNormValues = norms;
    cachedFieldName = field;
    cachedSimilarity = sim;
    if (DEBUG) System.err.println("MemoryIndexReader.norms: " + field + ":" + value + ":" + numTokens);
  }
  return norms;
}
项目:NYBC    文件:MemoryIndex.java   
@Override
public NumericDocValues getNormValues(String field) {
  FieldInfo fieldInfo = fieldInfos.get(field);
  if (fieldInfo == null || fieldInfo.omitsNorms())
    return null;
  NumericDocValues norms = cachedNormValues;
  Similarity sim = getSimilarity();
  if (!field.equals(cachedFieldName) || sim != cachedSimilarity) { // not cached?
    Info info = getInfo(field);
    int numTokens = info != null ? info.numTokens : 0;
    int numOverlapTokens = info != null ? info.numOverlapTokens : 0;
    float boost = info != null ? info.getBoost() : 1.0f; 
    FieldInvertState invertState = new FieldInvertState(field, 0, numTokens, numOverlapTokens, 0, boost);
    long value = sim.computeNorm(invertState);
    norms = new MemoryIndexNormDocValues(value);
    // cache it for future reuse
    cachedNormValues = norms;
    cachedFieldName = field;
    cachedSimilarity = sim;
    if (DEBUG) System.err.println("MemoryIndexReader.norms: " + field + ":" + value + ":" + numTokens);
  }
  return norms;
}
项目:read-open-source-code    文件:MemoryIndex.java   
@Override
public NumericDocValues getNormValues(String field) {
  FieldInfo fieldInfo = fieldInfos.get(field);
  if (fieldInfo == null || fieldInfo.omitsNorms())
    return null;
  NumericDocValues norms = cachedNormValues;
  Similarity sim = getSimilarity();
  if (!field.equals(cachedFieldName) || sim != cachedSimilarity) { // not cached?
    Info info = getInfo(field);
    int numTokens = info != null ? info.numTokens : 0;
    int numOverlapTokens = info != null ? info.numOverlapTokens : 0;
    float boost = info != null ? info.getBoost() : 1.0f; 
    FieldInvertState invertState = new FieldInvertState(field, 0, numTokens, numOverlapTokens, 0, boost);
    long value = sim.computeNorm(invertState);
    norms = new MemoryIndexNormDocValues(value);
    // cache it for future reuse
    cachedNormValues = norms;
    cachedFieldName = field;
    cachedSimilarity = sim;
    if (DEBUG) System.err.println("MemoryIndexReader.norms: " + field + ":" + value + ":" + numTokens);
  }
  return norms;
}
项目:read-open-source-code    文件:MemoryIndex.java   
@Override
public NumericDocValues getNormValues(String field) {
  FieldInfo fieldInfo = fieldInfos.get(field);
  if (fieldInfo == null || fieldInfo.omitsNorms())
    return null;
  NumericDocValues norms = cachedNormValues;
  Similarity sim = getSimilarity();
  if (!field.equals(cachedFieldName) || sim != cachedSimilarity) { // not cached?
    Info info = getInfo(field);
    int numTokens = info != null ? info.numTokens : 0;
    int numOverlapTokens = info != null ? info.numOverlapTokens : 0;
    float boost = info != null ? info.getBoost() : 1.0f; 
    FieldInvertState invertState = new FieldInvertState(field, 0, numTokens, numOverlapTokens, 0, boost);
    long value = sim.computeNorm(invertState);
    norms = new MemoryIndexNormDocValues(value);
    // cache it for future reuse
    cachedNormValues = norms;
    cachedFieldName = field;
    cachedSimilarity = sim;
    if (DEBUG) System.err.println("MemoryIndexReader.norms: " + field + ":" + value + ":" + numTokens);
  }
  return norms;
}
项目:read-open-source-code    文件:MemoryIndex.java   
@Override
public NumericDocValues getNormValues(String field) {
  FieldInfo fieldInfo = fieldInfos.get(field);
  if (fieldInfo == null || fieldInfo.omitsNorms())
    return null;
  NumericDocValues norms = cachedNormValues;
  Similarity sim = getSimilarity();
  if (!field.equals(cachedFieldName) || sim != cachedSimilarity) { // not cached?
    Info info = getInfo(field);
    int numTokens = info != null ? info.numTokens : 0;
    int numOverlapTokens = info != null ? info.numOverlapTokens : 0;
    float boost = info != null ? info.getBoost() : 1.0f; 
    FieldInvertState invertState = new FieldInvertState(field, 0, numTokens, numOverlapTokens, 0, boost);
    long value = sim.computeNorm(invertState);
    norms = new MemoryIndexNormDocValues(value);
    // cache it for future reuse
    cachedNormValues = norms;
    cachedFieldName = field;
    cachedSimilarity = sim;
    if (DEBUG) System.err.println("MemoryIndexReader.norms: " + field + ":" + value + ":" + numTokens);
  }
  return norms;
}
项目:Maskana-Gestor-de-Conocimiento    文件:MemoryIndex.java   
@Override
public NumericDocValues getNormValues(String field) {
  FieldInfo fieldInfo = fieldInfos.get(field);
  if (fieldInfo == null || fieldInfo.omitsNorms())
    return null;
  NumericDocValues norms = cachedNormValues;
  Similarity sim = getSimilarity();
  if (!field.equals(cachedFieldName) || sim != cachedSimilarity) { // not cached?
    Info info = getInfo(field);
    int numTokens = info != null ? info.numTokens : 0;
    int numOverlapTokens = info != null ? info.numOverlapTokens : 0;
    float boost = info != null ? info.getBoost() : 1.0f; 
    FieldInvertState invertState = new FieldInvertState(field, 0, numTokens, numOverlapTokens, 0, boost);
    long value = sim.computeNorm(invertState);
    norms = new MemoryIndexNormDocValues(value);
    // cache it for future reuse
    cachedNormValues = norms;
    cachedFieldName = field;
    cachedSimilarity = sim;
    if (DEBUG) System.err.println("MemoryIndexReader.norms: " + field + ":" + value + ":" + numTokens);
  }
  return norms;
}
项目:lams    文件:SimilarityBase.java   
/** Encodes the document length in the same way as {@link TFIDFSimilarity}. */
@Override
public long computeNorm(FieldInvertState state) {
  final float numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:lams    文件:DefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:ir-generalized-translation-models    文件:BM25SimilarityLossless.java   
@Override
public final long computeNorm(FieldInvertState state) {
  final float numTerms = discountOverlaps ? state.getLength() - state.getNumOverlap() : state.getLength();
  // Dividing by the square of the boost is to mimic behavior of the old BM25 formula
  final float boost = state.getBoost();
  return (long) ( numTerms / (boost*boost) );
}
项目:linden    文件:LindenSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link org.apache.lucene.index.FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  org.apache.lucene.index.FieldInvertState#getLength()} - {@link
 *  org.apache.lucene.index.FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:search    文件:TestLongNormValueSource.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link org.apache.lucene.index.FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  org.apache.lucene.index.FieldInvertState#getLength()} - {@link
 *  org.apache.lucene.index.FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps) {
    numTerms = state.getLength() - state.getNumOverlap();
  } else {
    numTerms = state.getLength();
  }
  return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:search    文件:SweetSpotSimilarity.java   
/**
 * Implemented as <code> state.getBoost() *
 * computeLengthNorm(numTokens) </code> where
 * numTokens does not count overlap tokens if
 * discountOverlaps is true by default or true for this
 * specific field. 
 */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTokens;

  if (discountOverlaps)
    numTokens = state.getLength() - state.getNumOverlap();
  else
    numTokens = state.getLength();

  return state.getBoost() * computeLengthNorm(numTokens);
}
项目:search    文件:SorterTestBase.java   
@Override
public long computeNorm(FieldInvertState state) {
  if (state.getName().equals(NORMS_FIELD)) {
    return Float.floatToIntBits(state.getBoost());
  } else {
    return in.computeNorm(state);
  }
}
项目:search    文件:SimilarityBase.java   
/** Encodes the document length in the same way as {@link TFIDFSimilarity}. */
@Override
public long computeNorm(FieldInvertState state) {
  final float numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:search    文件:DefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:search    文件:TestSimilarityBase.java   
public void testDiscountOverlapsBoost() throws IOException {
  DefaultSimilarity expected = new DefaultSimilarity();
  SimilarityBase actual = new DFRSimilarity(new BasicModelIne(), new AfterEffectB(), new NormalizationH2());
  expected.setDiscountOverlaps(false);
  actual.setDiscountOverlaps(false);
  FieldInvertState state = new FieldInvertState("foo");
  state.setLength(5);
  state.setNumOverlap(2);
  state.setBoost(3);
  assertEquals(expected.computeNorm(state), actual.computeNorm(state));
  expected.setDiscountOverlaps(true);
  actual.setDiscountOverlaps(true);
  assertEquals(expected.computeNorm(state), actual.computeNorm(state));
}
项目:SolrPlugins    文件:DiceDefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
    final int numTerms;
    if (discountOverlaps)
        numTerms = state.getLength() - state.getNumOverlap();
    else
        numTerms = state.getLength();
    return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:NYBC    文件:SweetSpotSimilarity.java   
/**
 * Implemented as <code> state.getBoost() *
 * computeLengthNorm(numTokens) </code> where
 * numTokens does not count overlap tokens if
 * discountOverlaps is true by default or true for this
 * specific field. 
 */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTokens;

  if (discountOverlaps)
    numTokens = state.getLength() - state.getNumOverlap();
  else
    numTokens = state.getLength();

  return state.getBoost() * computeLengthNorm(numTokens);
}
项目:NYBC    文件:SimilarityBase.java   
/** Encodes the document length in the same way as {@link TFIDFSimilarity}. */
@Override
public long computeNorm(FieldInvertState state) {
  final float numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength() / state.getBoost();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:NYBC    文件:DefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
 return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:read-open-source-code    文件:SimilarityBase.java   
/** Encodes the document length in the same way as {@link TFIDFSimilarity}. */
@Override
public long computeNorm(FieldInvertState state) {
  final float numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:read-open-source-code    文件:DefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
 return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:read-open-source-code    文件:SweetSpotSimilarity.java   
/**
 * Implemented as <code> state.getBoost() *
 * computeLengthNorm(numTokens) </code> where
 * numTokens does not count overlap tokens if
 * discountOverlaps is true by default or true for this
 * specific field. 
 */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTokens;

  if (discountOverlaps)
    numTokens = state.getLength() - state.getNumOverlap();
  else
    numTokens = state.getLength();

  return state.getBoost() * computeLengthNorm(numTokens);
}
项目:read-open-source-code    文件:SimilarityBase.java   
/** Encodes the document length in the same way as {@link TFIDFSimilarity}. */
@Override
public long computeNorm(FieldInvertState state) {
  final float numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:read-open-source-code    文件:DefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
 return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:read-open-source-code    文件:SweetSpotSimilarity.java   
/**
 * Implemented as <code> state.getBoost() *
 * computeLengthNorm(numTokens) </code> where
 * numTokens does not count overlap tokens if
 * discountOverlaps is true by default or true for this
 * specific field. 
 */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTokens;

  if (discountOverlaps)
    numTokens = state.getLength() - state.getNumOverlap();
  else
    numTokens = state.getLength();

  return state.getBoost() * computeLengthNorm(numTokens);
}
项目:read-open-source-code    文件:SimilarityBase.java   
/** Encodes the document length in the same way as {@link TFIDFSimilarity}. */
@Override
public long computeNorm(FieldInvertState state) {
  final float numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:read-open-source-code    文件:DefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:read-open-source-code    文件:SweetSpotSimilarity.java   
/**
 * Implemented as <code> state.getBoost() *
 * computeLengthNorm(numTokens) </code> where
 * numTokens does not count overlap tokens if
 * discountOverlaps is true by default or true for this
 * specific field. 
 */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTokens;

  if (discountOverlaps)
    numTokens = state.getLength() - state.getNumOverlap();
  else
    numTokens = state.getLength();

  return state.getBoost() * computeLengthNorm(numTokens);
}
项目:opensearchserver    文件:FairSimilarity.java   
@Override
final public float computeNorm(String field, FieldInvertState state) {
    final int numTerms;
    if (discountOverlaps)
        numTerms = state.getLength() - state.getNumOverlap();
    else
        numTerms = state.getLength();
    return state.getBoost() * ((float) (1.0 / numTerms));
}
项目:Maskana-Gestor-de-Conocimiento    文件:SweetSpotSimilarity.java   
/**
 * Implemented as <code> state.getBoost() *
 * computeLengthNorm(numTokens) </code> where
 * numTokens does not count overlap tokens if
 * discountOverlaps is true by default or true for this
 * specific field. 
 */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTokens;

  if (discountOverlaps)
    numTokens = state.getLength() - state.getNumOverlap();
  else
    numTokens = state.getLength();

  return state.getBoost() * computeLengthNorm(numTokens);
}
项目:Maskana-Gestor-de-Conocimiento    文件:SorterTestBase.java   
@Override
public long computeNorm(FieldInvertState state) {
  if (state.getName().equals(NORMS_FIELD)) {
    return Float.floatToIntBits(state.getBoost());
  } else {
    return in.computeNorm(state);
  }
}
项目:Maskana-Gestor-de-Conocimiento    文件:SimilarityBase.java   
/** Encodes the document length in the same way as {@link TFIDFSimilarity}. */
@Override
public long computeNorm(FieldInvertState state) {
  final float numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:Maskana-Gestor-de-Conocimiento    文件:DefaultSimilarity.java   
/** Implemented as
 *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
 *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
 *  #setDiscountOverlaps} is false, else it's {@link
 *  FieldInvertState#getLength()} - {@link
 *  FieldInvertState#getNumOverlap()}.
 *
 *  @lucene.experimental */
@Override
public float lengthNorm(FieldInvertState state) {
  final int numTerms;
  if (discountOverlaps)
    numTerms = state.getLength() - state.getNumOverlap();
  else
    numTerms = state.getLength();
 return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestSimilarityBase.java   
public void testDiscountOverlapsBoost() throws IOException {
  DefaultSimilarity expected = new DefaultSimilarity();
  SimilarityBase actual = new DFRSimilarity(new BasicModelIne(), new AfterEffectB(), new NormalizationH2());
  expected.setDiscountOverlaps(false);
  actual.setDiscountOverlaps(false);
  FieldInvertState state = new FieldInvertState("foo");
  state.setLength(5);
  state.setNumOverlap(2);
  state.setBoost(3);
  assertEquals(expected.computeNorm(state), actual.computeNorm(state));
  expected.setDiscountOverlaps(true);
  actual.setDiscountOverlaps(true);
  assertEquals(expected.computeNorm(state), actual.computeNorm(state));
}
项目:elasticsearch_my    文件:IndexModuleTests.java   
@Override
public long computeNorm(FieldInvertState state) {
    return delegate.computeNorm(state);
}
项目:lams    文件:BM25Similarity.java   
@Override
public final long computeNorm(FieldInvertState state) {
  final int numTerms = discountOverlaps ? state.getLength() - state.getNumOverlap() : state.getLength();
  return encodeNormValue(state.getBoost(), numTerms);
}
项目:lams    文件:PerFieldSimilarityWrapper.java   
@Override
public final long computeNorm(FieldInvertState state) {
  return get(state.getName()).computeNorm(state);
}
项目:lams    文件:MultiSimilarity.java   
@Override
public long computeNorm(FieldInvertState state) {
  return sims[0].computeNorm(state);
}
项目:lams    文件:TFIDFSimilarity.java   
@Override
public final long computeNorm(FieldInvertState state) {
  float normValue = lengthNorm(state);
  return encodeNormValue(normValue);
}