Examples of TermInfo


Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    assertConsistentLessThan( d, c );
  }

  private WeightedPhraseInfo newInfo( int startOffset, int endOffset, float boost ) {
    LinkedList< TermInfo > infos = new LinkedList<>();
    infos.add( new TermInfo( TestUtil.randomUnicodeString(random()), startOffset, endOffset, 0, 0 ) );
    return new WeightedPhraseInfo( infos, boost );
  }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    assertEquals ("the(153,156,23)", stack.pop().toString());
    assertEquals ("the(195,198,31)", stack.pop().toString());
  }

  public void testTermInfoComparisonConsistency() {
    TermInfo a = new TermInfo( TestUtil.randomUnicodeString(random()), 0, 0, 0, 1 );
    TermInfo b = new TermInfo( TestUtil.randomUnicodeString(random()), 0, 0, 1, 1 );
    TermInfo c = new TermInfo( TestUtil.randomUnicodeString(random()), 0, 0, 2, 1 );
    TermInfo d = new TermInfo( TestUtil.randomUnicodeString(random()), 0, 0, 0, 1 );

    assertConsistentEquals( a, a );
    assertConsistentEquals( b, b );
    assertConsistentEquals( c, c );
    assertConsistentEquals( d, d );
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

     
      // We keep TermInfos for further operations
      termsInfos = new ArrayList<>( terms );
     
      termsOffsets = new ArrayList<>( terms.size() );
      TermInfo ti = terms.get( 0 );
      termsOffsets.add( new Toffs( ti.getStartOffset(), ti.getEndOffset() ) );
      if( terms.size() == 1 ){
        return;
      }
      int pos = ti.getPosition();
      for( int i = 1; i < terms.size(); i++ ){
        ti = terms.get( i );
        if( ti.getPosition() - pos == 1 ){
          Toffs to = termsOffsets.get( termsOffsets.size() - 1 );
          to.setEndOffset( ti.getEndOffset() );
        }
        else{
          termsOffsets.add( new Toffs( ti.getStartOffset(), ti.getEndOffset() ) );
        }
        pos = ti.getPosition();
      }
    }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    bq.add( tq( "Mac" ), Occur.SHOULD );
    bq.add( tq( "MacBook" ), Occur.SHOULD );
    FieldQuery fq = new FieldQuery( bq, true, true );
    FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
    assertEquals( 1, stack.termList.size() );
    TermInfo ti = stack.pop();
    assertEquals("Mac(11,20,3)", ti.toString());
    assertEquals("MacBook(11,20,3)", ti.getNext().toString());
    assertSame(ti, ti.getNext().getNext());
  }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    bq.add( tq( "pc" ), Occur.SHOULD );
    bq.add( pqF( "personal", "computer" ), Occur.SHOULD );
    FieldQuery fq = new FieldQuery( bq, true, true );
    FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
    assertEquals( 2, stack.termList.size() );
    TermInfo ti = stack.pop();
    assertEquals( "pc(3,5,1)", ti.toString());
    assertEquals( "personal(3,5,1)", ti.getNext().toString());
    assertSame(ti, ti.getNext().getNext());
    assertEquals( "computer(3,5,2)", stack.pop().toString() );
  }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    bq.add( tq( "pc" ), Occur.SHOULD );
    bq.add( pqF( "personal", "computer" ), Occur.SHOULD );
    FieldQuery fq = new FieldQuery( bq, true, true );
    FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
    assertEquals( 2, stack.termList.size() );
    TermInfo ti = stack.pop();
    assertEquals("pc(3,20,1)", ti.toString());
    assertEquals("personal(3,20,1)", ti.getNext().toString());
    assertSame(ti, ti.getNext().getNext());
    assertEquals( "computer(3,20,2)", stack.pop().toString() );
  }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    // phraseHighlight = true, fieldMatch = true
    FieldQuery fq = new FieldQuery( query, true, true );
   
    // "a"
    List<TermInfo> phraseCandidate = new ArrayList<>();
    phraseCandidate.add( new TermInfo( "a", 0, 1, 0, 1 ) );
    assertNull( fq.searchPhrase( F, phraseCandidate ) );
    // "a b"
    phraseCandidate.add( new TermInfo( "b", 2, 3, 1, 1 ) );
    assertNull( fq.searchPhrase( F, phraseCandidate ) );
    // "a b c"
    phraseCandidate.add( new TermInfo( "c", 4, 5, 2, 1 ) );
    assertNotNull( fq.searchPhrase( F, phraseCandidate ) );
    assertNull( fq.searchPhrase( "x", phraseCandidate ) );

    // phraseHighlight = true, fieldMatch = false
    fq = new FieldQuery( query, true, false );
   
    // "a b c"
    assertNotNull( fq.searchPhrase( F, phraseCandidate ) );
    assertNotNull( fq.searchPhrase( "x", phraseCandidate ) );

    // phraseHighlight = false, fieldMatch = true
    fq = new FieldQuery( query, false, true );
   
    // "a"
    phraseCandidate.clear();
    phraseCandidate.add( new TermInfo( "a", 0, 1, 0, 1 ) );
    assertNotNull( fq.searchPhrase( F, phraseCandidate ) );
    // "a b"
    phraseCandidate.add( new TermInfo( "b", 2, 3, 1, 1 ) );
    assertNull( fq.searchPhrase( F, phraseCandidate ) );
    // "a b c"
    phraseCandidate.add( new TermInfo( "c", 4, 5, 2, 1 ) );
    assertNotNull( fq.searchPhrase( F, phraseCandidate ) );
    assertNull( fq.searchPhrase( "x", phraseCandidate ) );
  }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    // phraseHighlight = true, fieldMatch = true
    FieldQuery fq = new FieldQuery( query, true, true );
   
    // "a b c" w/ position-gap = 2
    List<TermInfo> phraseCandidate = new ArrayList<>();
    phraseCandidate.add( new TermInfo( "a", 0, 1, 0, 1 ) );
    phraseCandidate.add( new TermInfo( "b", 2, 3, 2, 1 ) );
    phraseCandidate.add( new TermInfo( "c", 4, 5, 4, 1 ) );
    assertNull( fq.searchPhrase( F, phraseCandidate ) );

    // "a b c"~1
    query = pqF( 1F, 1, "a", "b", "c" );

    // phraseHighlight = true, fieldMatch = true
    fq = new FieldQuery( query, true, true );
   
    // "a b c" w/ position-gap = 2
    assertNotNull( fq.searchPhrase( F, phraseCandidate ) );
   
    // "a b c" w/ position-gap = 3
    phraseCandidate.clear();
    phraseCandidate.add( new TermInfo( "a", 0, 1, 0, 1 ) );
    phraseCandidate.add( new TermInfo( "b", 2, 3, 3, 1 ) );
    phraseCandidate.add( new TermInfo( "c", 4, 5, 6, 1 ) );
    assertNull( fq.searchPhrase( F, phraseCandidate ) );
  }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    FieldQuery fq = new FieldQuery( query, reader, true, true );
    QueryPhraseMap qpm = fq.getFieldTermMap(F, "defg");
    assertNotNull (qpm);
    assertNull (fq.getFieldTermMap(F, "dog"));
    List<TermInfo> phraseCandidate = new ArrayList<>();
    phraseCandidate.add( new TermInfo( "defg", 0, 12, 0, 1 ) );
    assertNotNull (fq.searchPhrase(F, phraseCandidate));
  }
View Full Code Here

Examples of org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo

    QueryPhraseMap nextMap = null;
    while( !fieldTermStack.isEmpty() && (phraseList.size() < phraseLimit) )
    {     
      phraseCandidate.clear();

      TermInfo ti = null;
      TermInfo first = null;
     
      first = ti = fieldTermStack.pop();
      currMap = fieldQuery.getFieldTermMap( field, ti.getText() );
      while (currMap == null && ti.getNext() != first) {
        ti = ti.getNext();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.