Package org.apache.lucene.index

Examples of org.apache.lucene.index.FieldInvertState


          numFieldsWithTermVectorsInDocument += eFieldTermDocInfoFactoriesByTermText.getValue().size();
        }
        termsInDocument += eFieldTermDocInfoFactoriesByTermText.getValue().size();

        if (eFieldTermDocInfoFactoriesByTermText.getKey().indexed && !eFieldTermDocInfoFactoriesByTermText.getKey().omitNorms) {
          final FieldInvertState invertState = new FieldInvertState();
          invertState.setBoost(eFieldTermDocInfoFactoriesByTermText.getKey().boost * document.getDocument().getBoost());
          invertState.setLength(eFieldTermDocInfoFactoriesByTermText.getKey().fieldLength);
          final float norm = similarity.computeNorm(eFieldTermDocInfoFactoriesByTermText.getKey().fieldName, invertState);
          normsByFieldNameAndDocumentNumber.get(eFieldTermDocInfoFactoriesByTermText.getKey().fieldName)[document.getDocumentNumber()] = similarity.encodeNormValue(norm);
        } else {
          System.currentTimeMillis();
        }
View Full Code Here


      if (fieldName != cachedFieldName || sim != cachedSimilarity) { // not cached?
        Info info = getInfo(fieldName);
        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(0, numTokens, numOverlapTokens, 0, boost);
        float n = sim.computeNorm(fieldName, invertState);
        byte norm = sim.encodeNormValue(n);
        norms = new byte[] {norm};
       
        // cache it for future reuse
View Full Code Here

                List<Number> bnorm = null;
                if (!field.getOmitNorms())
                {
                    bnorm = new ArrayList<Number>();

                    final FieldInvertState invertState = new FieldInvertState();
                    invertState.setBoost(doc.getBoost() * field.getBoost());
                    invertState.setLength(tokensInField);
                    final float norm = similarity.computeNorm(field.name(), invertState);

                    bnorm.add(Similarity.getDefault().encodeNormValue(norm));
                }

View Full Code Here

      if (fieldName != cachedFieldName || sim != cachedSimilarity) { // not cached?
        Info info = getInfo(fieldName);
        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(0, numTokens, numOverlapTokens, 0, boost);
        float n = sim.computeNorm(fieldName, invertState);
        byte norm = sim.encodeNormValue(n);
        norms = new byte[] {norm};
       
        // cache it for future reuse
View Full Code Here

          numFieldsWithTermVectorsInDocument += eFieldTermDocInfoFactoriesByTermText.getValue().size();
        }
        termsInDocument += eFieldTermDocInfoFactoriesByTermText.getValue().size();

        if (eFieldTermDocInfoFactoriesByTermText.getKey().indexed && !eFieldTermDocInfoFactoriesByTermText.getKey().omitNorms) {
          final FieldInvertState invertState = new FieldInvertState();
          invertState.setBoost(eFieldTermDocInfoFactoriesByTermText.getKey().boost * document.getDocument().getBoost());
          invertState.setLength(eFieldTermDocInfoFactoriesByTermText.getKey().fieldLength);
          final float norm = similarity.computeNorm(eFieldTermDocInfoFactoriesByTermText.getKey().fieldName, invertState);
          normsByFieldNameAndDocumentNumber.get(eFieldTermDocInfoFactoriesByTermText.getKey().fieldName)[document.getDocumentNumber()] = similarity.encodeNormValue(norm);
        } else {
          System.currentTimeMillis();
        }
View Full Code Here

    Similarity d = new DefaultSimilarity();
    Similarity s = ss;


    // base case, should degrade
    final FieldInvertState invertState = new FieldInvertState();
    invertState.setBoost(1.0f);
    for (int i = 1; i < 1000; i++) {
      invertState.setLength(i);
      assertEquals("base case: i="+i,
                   d.computeNorm("foo", invertState),
                   s.computeNorm("foo", invertState),
                   0.0f);
    }

    // make a sweet spot
 
    ss.setLengthNormFactors(3,10,0.5f);
 
    for (int i = 3; i <=10; i++) {
      invertState.setLength(i);
      assertEquals("3,10: spot i="+i,
                   1.0f,
                   s.computeNorm("foo", invertState),
                   0.0f);
    }
 
    for (int i = 10; i < 1000; i++) {
      invertState.setLength(i-9);
      final float normD = d.computeNorm("foo", invertState);
      invertState.setLength(i);
      final float normS = s.computeNorm("foo", invertState);
      assertEquals("3,10: 10<x : i="+i,
                   normD,
                   normS,
                   0.0f);
    }


    // seperate sweet spot for certain fields

    ss.setLengthNormFactors("bar",8,13, 0.5f, false);
    ss.setLengthNormFactors("yak",6,9, 0.5f, false);

 
    for (int i = 3; i <=10; i++) {
      invertState.setLength(i);
      assertEquals("f: 3,10: spot i="+i,
                   1.0f,
                   s.computeNorm("foo", invertState),
                   0.0f);
    }
    for (int i = 10; i < 1000; i++) {
      invertState.setLength(i-9);
      final float normD = d.computeNorm("foo", invertState);
      invertState.setLength(i);
      final float normS = s.computeNorm("foo", invertState);
      assertEquals("f: 3,10: 10<x : i="+i,
                   normD,
                   normS,
                   0.0f);
    }
    for (int i = 8; i <=13; i++) {
      invertState.setLength(i);
      assertEquals("f: 8,13: spot i="+i,
                   1.0f,
                   s.computeNorm("bar", invertState),
                   0.0f);
    }
    for (int i = 6; i <=9; i++) {
      invertState.setLength(i);
      assertEquals("f: 6,9: spot i="+i,
                   1.0f,
                   s.computeNorm("yak", invertState),
                   0.0f);
    }
    for (int i = 13; i < 1000; i++) {
      invertState.setLength(i-12);
      final float normD = d.computeNorm("foo", invertState);
      invertState.setLength(i);
      final float normS = s.computeNorm("bar", invertState);
      assertEquals("f: 8,13: 13<x : i="+i,
                   normD,
                   normS,
                   0.0f);
    }
    for (int i = 9; i < 1000; i++) {
      invertState.setLength(i-8);
      final float normD = d.computeNorm("foo", invertState);
      invertState.setLength(i);
      final float normS = s.computeNorm("yak", invertState);
      assertEquals("f: 6,9: 9<x : i="+i,
                   normD,
                   normS,
                   0.0f);
    }


    // steepness

    ss.setLengthNormFactors("a",5,8,0.5f, false);
    ss.setLengthNormFactors("b",5,8,0.1f, false);

    for (int i = 9; i < 1000; i++) {
      invertState.setLength(i);
      final float normSS = ss.computeNorm("a", invertState);
      final float normS = s.computeNorm("b", invertState);
      assertTrue("s: i="+i+" : a="+normSS+
                 " < b="+normS,
                 normSS < normS);
View Full Code Here

      if (fieldName != cachedFieldName || sim != cachedSimilarity) { // not cached?
        Info info = getInfo(fieldName);
        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(0, numTokens, numOverlapTokens, 0, boost);
        float n = sim.computeNorm(fieldName, invertState);
        byte norm = Similarity.encodeNorm(n);
        norms = new byte[] {norm};
       
        // cache it for future reuse
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.FieldInvertState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.