Package org.apache.lucene.index

Examples of org.apache.lucene.index.IndexableField.numericValue()


                    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>();
View Full Code Here


                }
                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

    /** 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

      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();
    }
   
    private Set<String> getRelevantFields(String... fields) {
      Set<String> relevantFields = new HashSet<String>();
      for (String relevantField : fields) {
View Full Code Here

    BytesRef f;
    while((f = inputIterator.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
      IndexableField weightField = doc.getField(WEIGHT_FIELD_NAME);
      assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
      assertTrue(inputIterator.payload().equals(doc.getField(PAYLOAD_FIELD_NAME).binaryValue()));
    }
   
    for (String invalidTerm : invalidDocTerms) {
      assertNotNull(docs.remove(invalidTerm));
View Full Code Here

    BytesRef f;
    while((f = inputIterator.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
      IndexableField weightField = doc.getField(WEIGHT_FIELD_NAME);
      assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
      assertEquals(inputIterator.payload(), null);
    }
   
    for (String invalidTerm : invalidDocTerms) {
      assertNotNull(docs.remove(invalidTerm));
View Full Code Here

    BytesRef f;
    while((f = inputIterator.next())!=null) {
      Document doc = docs.remove(f.utf8ToString());
      assertTrue(f.equals(new BytesRef(doc.get(FIELD_NAME))));
      IndexableField weightField = doc.getField(WEIGHT_FIELD_NAME);
      assertEquals(inputIterator.weight(), (weightField != null) ? weightField.numericValue().longValue() : 0);
      assertEquals(inputIterator.payload(), null);
    }
   
    for (String invalidTerm : invalidDocTerms) {
      assertNotNull(docs.remove(invalidTerm));
View Full Code Here

     * If no value is found, then the weight is 0.
     */
    protected long getWeight(Document doc, int docId) {
      IndexableField weight = doc.getField(weightField);
      if (weight != null) { // found weight as stored
        return (weight.numericValue() != null) ? weight.numericValue().longValue() : 0;
      } else if (weightValues != null) {  // found weight as NumericDocValue
        return weightValues.get(docId);
      } else { // fall back
        return 0;
      }
View Full Code Here

     * If no value is found, then the weight is 0.
     */
    protected long getWeight(Document doc, int docId) {
      IndexableField weight = doc.getField(weightField);
      if (weight != null) { // found weight as stored
        return (weight.numericValue() != null) ? weight.numericValue().longValue() : 0;
      } else if (weightValues != null) {  // found weight as NumericDocValue
        return weightValues.get(docId);
      } else { // fall back
        return 0;
      }
View Full Code Here

      DirectoryReader reader = DirectoryReader.open(directory);
      int numDocs = reader.numDocs();
      for (int d = 0; d < numDocs; d++) {
        Document document = reader.document(d);
        IndexableField field = document.getField("id");
        Integer id = (Integer) field.numericValue();
        int partition = partitioner.getPartition(new IntWritable(id), null, totalShardCount);
        assertEquals(i, partition);
      }
      reader.close();
    }
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.