Examples of Payload


Examples of org.apache.lucene.index.Payload

    public boolean incrementToken() throws IOException {
     
      if (input.incrementToken()) {
        if (fieldName.equals(FIELD))
        {
          payloadAtt.setPayload(new Payload(payloadField));
        }
        else if (fieldName.equals(MULTI_FIELD))
        {
          if (numSeen  % 2 == 0)
          {
            payloadAtt.setPayload(new Payload(payloadMultiField1));
          }
          else
          {
            payloadAtt.setPayload(new Payload(payloadMultiField2));
          }
          numSeen++;
        }
        return true;
      }
View Full Code Here

Examples of org.apache.lucene.index.Payload

      if (nextToken == null) {
        prefixExhausted = true;
      } else {
        previousPrefixToken.reinit(nextToken);
        // Make it a deep copy
        Payload p = previousPrefixToken.getPayload();
        if (p != null) {
          previousPrefixToken.setPayload((Payload) p.clone());
        }
        setCurrentToken(nextToken);
        return true;
      }
    }
View Full Code Here

Examples of org.apache.lucene.index.Payload

    @Override
    public boolean incrementToken() throws IOException {
      boolean hasNext = input.incrementToken();
      if (hasNext) {
        if (fieldName.equals("field")) {
          payloadAtt.setPayload(new Payload(payloadField));
        } else if (fieldName.equals("multiField")) {
          if (numSeen % 2 == 0) {
            payloadAtt.setPayload(new Payload(payloadMultiField1));
          } else {
            payloadAtt.setPayload(new Payload(payloadMultiField2));
          }
          numSeen++;
        }
        return true;
      } else {
View Full Code Here

Examples of org.apache.lucene.index.Payload

    @Override
    public boolean incrementToken() throws IOException {
      boolean result = false;
      if (input.incrementToken() == true){
        if (numSeen % 2 == 0) {
          payAtt.setPayload(new Payload(payload2));
        } else {
          payAtt.setPayload(new Payload(payload4));
        }
        numSeen++;
        result = true;
      }
      return result;
View Full Code Here

Examples of org.apache.lucene.index.Payload

    char[] buf = t.termBuffer();
    Token copy = (Token) TestSimpleAttributeImpls.assertCloneIsEqual(t);
    assertEquals(t.term(), copy.term());
    assertNotSame(buf, copy.termBuffer());

    Payload pl = new Payload(new byte[]{1,2,3,4});
    t.setPayload(pl);
    copy = (Token) TestSimpleAttributeImpls.assertCloneIsEqual(t);
    assertEquals(pl, copy.getPayload());
    assertNotSame(pl, copy.getPayload());
  }
View Full Code Here

Examples of org.apache.lucene.index.Payload

    char[] buf = t.termBuffer();
    copy = (Token) TestSimpleAttributeImpls.assertCopyIsEqual(t);
    assertEquals(t.term(), copy.term());
    assertNotSame(buf, copy.termBuffer());

    Payload pl = new Payload(new byte[]{1,2,3,4});
    t.setPayload(pl);
    copy = (Token) TestSimpleAttributeImpls.assertCopyIsEqual(t);
    assertEquals(pl, copy.getPayload());
    assertNotSame(pl, copy.getPayload());
  }
View Full Code Here

Examples of org.apache.lucene.index.Payload

            f.setOmitNorms(true);
            document.add(f);
            if (i > 4) {
              final List<Token> tokens = new ArrayList<Token>(2);
              Token t = createToken("the", 0, 2, "text");
              t.setPayload(new Payload(new byte[]{1, 2, 3}));
              tokens.add(t);
              t = createToken("end", 3, 5, "text");
              t.setPayload(new Payload(new byte[]{2}));
              tokens.add(t);
              tokens.add(createToken("fin", 7, 9));
              TokenStream ts = new TokenStream(Token.TOKEN_ATTRIBUTE_FACTORY) {
                final AttributeImpl reusableToken = (AttributeImpl) addAttribute(TermAttribute.class);
                Iterator<Token> it = tokens.iterator();
View Full Code Here

Examples of org.apache.lucene.index.Payload

            k = ATTRIBUTE_MAPPING.get(k);
          }
         
          // TODO: special handling for payloads - move this to ResponseWriter?
          if (value instanceof Payload) {
            Payload p = (Payload) value;
            if( null != p ) {
              BigInteger bi = new BigInteger( p.getData() );
              String ret = bi.toString( 16 );
              if (ret.length() % 2 != 0) {
                // Pad with 0
                ret = "0"+ret;
              }
View Full Code Here

Examples of org.apache.lucene.index.Payload

  }

  @Test
  public void testSpanPayloadCheck() throws Exception {
    SpanTermQuery term1 = new SpanTermQuery(new Term("field", "five"));
    Payload pay = new Payload(("pos: " + 5).getBytes());
    SpanQuery query = new SpanPayloadCheckQuery(term1, Collections.singletonList(pay.getData()));
    checkHits(query, new int[]
      {1125, 1135, 1145, 1155, 1165, 1175, 1185, 1195, 1225, 1235, 1245, 1255, 1265, 1275, 1285, 1295, 1325, 1335, 1345, 1355, 1365, 1375, 1385, 1395, 1425, 1435, 1445, 1455, 1465, 1475, 1485, 1495, 1525, 1535, 1545, 1555, 1565, 1575, 1585, 1595, 1625, 1635, 1645, 1655, 1665, 1675, 1685, 1695, 1725, 1735, 1745, 1755, 1765, 1775, 1785, 1795, 1825, 1835, 1845, 1855, 1865, 1875, 1885, 1895, 1925, 1935, 1945, 1955, 1965, 1975, 1985, 1995});
    assertTrue(searcher.explain(query, 1125).getValue() > 0.0f);

    SpanTermQuery term2 = new SpanTermQuery(new Term("field", "hundred"));
    SpanNearQuery snq;
    SpanQuery[] clauses;
    List<byte[]> list;
    Payload pay2;
    clauses = new SpanQuery[2];
    clauses[0] = term1;
    clauses[1] = term2;
    snq = new SpanNearQuery(clauses, 0, true);
    pay = new Payload(("pos: " + 0).getBytes());
    pay2 = new Payload(("pos: " + 1).getBytes());
    list = new ArrayList<byte[]>();
    list.add(pay.getData());
    list.add(pay2.getData());
    query = new SpanNearPayloadCheckQuery(snq, list);
    checkHits(query, new int[]
      {500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599});
    clauses = new SpanQuery[3];
    clauses[0] = term1;
    clauses[1] = term2;
    clauses[2] = new SpanTermQuery(new Term("field", "five"));
    snq = new SpanNearQuery(clauses, 0, true);
    pay = new Payload(("pos: " + 0).getBytes());
    pay2 = new Payload(("pos: " + 1).getBytes());
    Payload pay3 = new Payload(("pos: " + 2).getBytes());
    list = new ArrayList<byte[]>();
    list.add(pay.getData());
    list.add(pay2.getData());
    list.add(pay3.getData());
    query = new SpanNearPayloadCheckQuery(snq, list);
    checkHits(query, new int[]
      {505});
  }
View Full Code Here

Examples of org.apache.lucene.index.Payload

    //this one's just right
    query = new SpanPositionRangeQuery(oneThousHunThree, 0, 6);
    checkHits(query, new int[]{1103, 1203,1303,1403,1503,1603,1703,1803,1903});

    Collection<byte[]> payloads = new ArrayList<byte[]>();
    Payload pay = new Payload(("pos: " + 0).getBytes());
    Payload pay2 = new Payload(("pos: " + 1).getBytes());
    Payload pay3 = new Payload(("pos: " + 3).getBytes());
    Payload pay4 = new Payload(("pos: " + 4).getBytes());
    payloads.add(pay.getData());
    payloads.add(pay2.getData());
    payloads.add(pay3.getData());
    payloads.add(pay4.getData());
    query = new SpanNearPayloadCheckQuery(oneThousHunThree, payloads);
    checkHits(query, new int[]{1103, 1203,1303,1403,1503,1603,1703,1803,1903});

  }
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.