Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexableField


                    // if we have already seen this GeoName and we are removing duplicates, skip to the next doc
                    continue;
                }
                String matchedName = INDEX_NAME.getValue(doc);
                if (!geoname.isAncestryResolved()) {
                    IndexableField parentIdField = doc.getField(IndexField.PARENT_ID.key());
                    Integer parentId = parentIdField != null && parentIdField.numericValue() != null ?
                            parentIdField.numericValue().intValue() : null;
                    if (parentId != null) {
                        Set<GeoName> geos = parentMap.get(parentId);
                        if (geos == null) {
                            geos = new HashSet<GeoName>();
                            parentMap.put(parentId, geos);
View Full Code Here


    super.close();
  }
 
  @Override
  protected PrintWriter lineFileOut(Document doc) {
    IndexableField titleField = doc.getField(DocMaker.TITLE_FIELD);
    if (titleField!=null && titleField.stringValue().startsWith("Category:")) {
      return categoryLineFileOut;
    }
    return super.lineFileOut(doc);
  }
View Full Code Here

   * document has to be added.</p>
   */
  public final void removeField(String name) {
    Iterator<IndexableField> it = fields.iterator();
    while (it.hasNext()) {
      IndexableField field = it.next();
      if (field.name().equals(name)) {
        it.remove();
        return;
      }
    }
  }
View Full Code Here

   * document has to be added.</p>
   */
  public final void removeFields(String name) {
    Iterator<IndexableField> it = fields.iterator();
    while (it.hasNext()) {
      IndexableField field = it.next();
      if (field.name().equals(name)) {
        it.remove();
      }
    }
  }
View Full Code Here

  @Override
  public final String toString() {
    StringBuilder buffer = new StringBuilder();
    buffer.append("Document<");
    for (int i = 0; i < fields.size(); i++) {
      IndexableField field = fields.get(i);
      buffer.append(field.toString());
      if (i != fields.size()-1)
        buffer.append(" ");
    }
    buffer.append(">");
    return buffer.toString();
View Full Code Here

    }
    sb.setLength(0);

    boolean sufficient = !checkSufficientFields;
    for (int i=0; i<fieldsToWrite.length; i++) {
      IndexableField f = doc.getField(fieldsToWrite[i]);
      String text = f == null ? "" : matcher.reset(f.stringValue()).replaceAll(" ").trim();
      sb.append(text).append(SEP);
      sufficient |= text.length()>0 && sufficientFields[i];
    }
    if (sufficient) {
      sb.setLength(sb.length()-1); // remove redundant last separator
View Full Code Here

      }

      // field does not store term vector info
      if (vector == null) {
        Document d = ir.document(docNum);
        IndexableField fields[] = d.getFields(fieldName);
        for (IndexableField field : fields) {
          final String stringValue = field.stringValue();
          if (stringValue != null) {
            addTermFrequencies(new StringReader(stringValue), termFreqMap, fieldName);
          }
View Full Code Here

        }

        doc = reader.document(currentDocId, relevantFields);
       
        if (hasPayloads) {
          IndexableField payload = doc.getField(payloadField);
          if (payload == null) {
            throw new IllegalArgumentException(payloadField + " does not exist");
          } else if (payload.binaryValue() == null) {
            throw new IllegalArgumentException(payloadField + " does not have binary value");
          }
          currentPayload = payload.binaryValue();
        }
       
        currentWeight = getWeight(currentDocId);
       
        IndexableField fieldVal = doc.getField(field);
        if (fieldVal == null) {
          throw new IllegalArgumentException(field + " does not exist");
        } else if(fieldVal.stringValue() == null) {
          throw new IllegalArgumentException(field + " does not have string value");
        }
       
        return new BytesRef(fieldVal.stringValue());
      }
      return null;
    }
View Full Code Here

      return hasPayloads;
    }

    /** Return the suggestion weight for this document */
    protected long getWeight(int docId) {
      IndexableField weight = doc.getField(weightField);
      if (weight == null) {
        throw new IllegalArgumentException(weightField + " does not exist");
      } else if (weight.numericValue() == null) {
        throw new IllegalArgumentException(weightField + " does not have numeric value");
      }
      return weight.numericValue().longValue();
    }
View Full Code Here

  public void testBinaryFieldInIndex()
    throws Exception
  {
    FieldType ft = new FieldType();
    ft.setStored(true);
    IndexableField binaryFldStored = new StoredField("binaryStored", binaryValStored.getBytes("UTF-8"));
    IndexableField stringFldStored = new Field("stringStored", binaryValStored, ft);

    Document doc = new Document();
   
    doc.add(binaryFldStored);
   
View Full Code Here

TOP

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

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.