congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SortField.getField
Code IndexAdd Tabnine to your IDE (free)

How to use
getField
method
in
org.apache.lucene.search.SortField

Best Java code snippets using org.apache.lucene.search.SortField.getField (Showing top 20 results out of 315)

origin: org.apache.lucene/lucene-core

private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOException {
 Sort indexSort = state.segmentInfo.getIndexSort();
 if (indexSort == null) {
  return null;
 }
 List<Sorter.DocComparator> comparators = new ArrayList<>();
 for (int i = 0; i < indexSort.getSort().length; i++) {
  SortField sortField = indexSort.getSort()[i];
  PerField perField = getPerField(sortField.getField());
  if (perField != null && perField.docValuesWriter != null &&
    finishedDocValues.contains(perField.fieldInfo.name) == false) {
    perField.docValuesWriter.finish(state.segmentInfo.maxDoc());
    Sorter.DocComparator cmp = perField.docValuesWriter.getDocComparator(state.segmentInfo.maxDoc(), sortField);
    comparators.add(cmp);
    finishedDocValues.add(perField.fieldInfo.name);
  } else {
   // safe to ignore, sort field with no values or already seen before
  }
 }
 Sorter sorter = new Sorter(indexSort);
 // returns null if the documents are already sorted
 return sorter.sort(state.segmentInfo.maxDoc(), comparators.toArray(new Sorter.DocComparator[comparators.size()]));
}
origin: org.apache.lucene/lucene-core

/** Wraps a {@link SortedSetDocValues} as a single-valued view if the field is an instance of {@link SortedSetSortField},
 * returns {@link SortedDocValues} for the field otherwise. */
static SortedDocValues getOrWrapSorted(LeafReader reader, SortField sortField) throws IOException {
 if (sortField instanceof SortedSetSortField) {
  SortedSetSortField sf = (SortedSetSortField) sortField;
  return SortedSetSelector.wrap(DocValues.getSortedSet(reader, sf.getField()), sf.getSelector());
 } else {
  return DocValues.getSorted(reader, sortField.getField());
 }
}
origin: org.apache.lucene/lucene-core

private void validateIndexSortDVType(Sort indexSort, String fieldName, DocValuesType dvType) {
 for (SortField sortField : indexSort.getSort()) {
  if (sortField.getField().equals(fieldName)) {
   switch (dvType) {
    case NUMERIC:
origin: org.apache.lucene/lucene-core

/** Wraps a {@link SortedNumericDocValues} as a single-valued view if the field is an instance of {@link SortedNumericSortField},
 * returns {@link NumericDocValues} for the field otherwise. */
static NumericDocValues getOrWrapNumeric(LeafReader reader, SortField sortField) throws IOException {
 if (sortField instanceof SortedNumericSortField) {
  SortedNumericSortField sf = (SortedNumericSortField) sortField;
  return SortedNumericSelector.wrap(DocValues.getSortedNumeric(reader, sf.getField()), sf.getSelector(), sf.getNumericType());
 } else {
  return DocValues.getNumeric(reader, sortField.getField());
 }
}
origin: org.elasticsearch/elasticsearch

private void validateIndexSortField(SortField sortField) {
  SortField.Type type = getSortFieldType(sortField);
  if (ALLOWED_INDEX_SORT_TYPES.contains(type) == false) {
    throw new IllegalArgumentException("invalid index sort field:[" + sortField.getField() + "]");
  }
}
origin: org.apache.lucene/lucene-core

SortField sortField = indexSort.getSort()[i];
SortField.Type sortType = sortField.getType();
output.writeString(sortField.getField());
int sortTypeID;
switch (sortField.getType()) {
   output.writeByte((byte) 2);
  } else {
   throw new AssertionError("unrecognized missing value for STRING field \"" + sortField.getField() + "\": " + missingValue);
origin: org.elasticsearch/elasticsearch

static Object convertValueFromSortField(Object value, SortField sortField, DocValueFormat format) {
  SortField.Type sortType = extractSortType(sortField);
  return convertValueFromSortType(sortField.getField(), sortType, value, format);
}
origin: rnewson/couchdb-lucene

for (final SortField field : sortFields) {
  final JSONObject col = new JSONObject();
  col.put("field", field.getField());
  col.put("reverse", field.getReverse());
origin: org.elasticsearch/elasticsearch

private static void toXContent(XContentBuilder builder, Sort sort) throws IOException {
  builder.startArray("sort");
  for (SortField field : sort.getSort()) {
    builder.startObject();
    builder.field("field", field.getField());
    if (field instanceof SortedNumericSortField) {
      builder.field("mode", ((SortedNumericSortField) field).getSelector()
        .toString().toLowerCase(Locale.ROOT));
    } else if (field instanceof SortedSetSortField) {
      builder.field("mode", ((SortedSetSortField) field).getSelector()
        .toString().toLowerCase(Locale.ROOT));
    }
    if (field.getMissingValue() != null) {
      builder.field("missing", field.getMissingValue().toString());
    }
    builder.field("reverse", field.getReverse());
    builder.endObject();
  }
  builder.endArray();
}
origin: org.elasticsearch/elasticsearch

  SortField newSortField = new SortField(sortField.getField(), SortField.Type.DOUBLE);
  newSortField.setMissingValue(sortField.getMissingValue());
  sortField = newSortField;
  SortField newSortField = new SortField(sortField.getField(), SortField.Type.STRING, sortField.getReverse());
  newSortField.setMissingValue(sortField.getMissingValue());
  sortField = newSortField;
  SortField newSortField = new SortField(sortField.getField(),
    ((SortedNumericSortField) sortField).getNumericType(),
    sortField.getReverse());
  throw new IllegalArgumentException("Cannot serialize SortField impl [" + sortField + "]");
if (sortField.getField() == null) {
  out.writeBoolean(false);
} else {
  out.writeBoolean(true);
  out.writeString(sortField.getField());
origin: org.elasticsearch/elasticsearch

out.writeString(field.getField());
if (field instanceof SortedSetSortField) {
  out.writeByte((byte) 0);
origin: apache/servicemix-bundles

private void validateIndexSortField(SortField sortField) {
  SortField.Type type = getSortFieldType(sortField);
  if (ALLOWED_INDEX_SORT_TYPES.contains(type) == false) {
    throw new IllegalArgumentException("invalid index sort field:[" + sortField.getField() + "]");
  }
}
origin: hibernate/hibernate-search

private void validateDistanceSortField(Iterable<EntityIndexBinding> targetedBindings, SortField sortField) {
  DocumentFieldMetadata documentFieldMetadata = findFieldMetadata( targetedBindings, sortField.getField() );
  if ( documentFieldMetadata == null ) {
    throw LOG.sortRequiresIndexedField( sortField.getClass(), sortField.getField() );
  }
  if ( !documentFieldMetadata.isSpatial() ) {
    throw LOG.distanceSortRequiresSpatialField( sortField.getField() );
  }
}
origin: hibernate/hibernate-search

private void validateNumericEncodingType(SortField sortField, NumericEncodingType sortEncodingType,
    NumericEncodingType indexEncodingType) {
  if ( sortEncodingType != indexEncodingType ) {
    throw LOG.sortTypeDoesNotMatchFieldType(
        String.valueOf( sortField.getType() ), String.valueOf( indexEncodingType ), sortField.getField()
    );
  }
}
origin: org.infinispan/infinispan-embedded-query

private void assertType(SortField sortField, FieldType actual, FieldType expected) {
  if ( actual != expected ) {
    throw LOG.sortTypeDoesNotMatchFieldType( String.valueOf( sortField.getType() ), String.valueOf( actual ), sortField.getField() );
  }
}
origin: metatron-app/metatron-discovery

private SortField getAvailableSortField(String propertyName, org.springframework.data.domain.Sort.Direction direction) {
 if(sortFieldMap.containsKey(propertyName)) {
  SortField availableSortField = sortFieldMap.get(propertyName);
  boolean reverse = direction == org.springframework.data.domain.Sort.Direction.DESC ? true : false;
  if(availableSortField.getType() != null) {
   return new SortField(availableSortField.getField(), availableSortField.getType(), reverse);
  } else {
   return new SortField(availableSortField.getField(), availableSortField.getComparatorSource(), reverse);
  }
 } else {
  return sortFieldMap.get("name");
 }
}
origin: hibernate/hibernate-search

private void validateNullSortField(SortField sortField) {
  if ( sortField.getType() != SortField.Type.DOC && sortField.getType() != SortField.Type.SCORE ) {
    throw LOG.sortRequiresIndexedField( sortField.getClass(), sortField.getField() );
  }
}
origin: org.infinispan/infinispan-query

@Test
public void testBuildSortForNullEncoding() {
 LuceneQueryParsingResult<Class<?>> result = parseAndTransform("select e from org.infinispan.query.dsl.embedded.impl.model.Employee e order by e.code DESC");
 Sort sort = result.getSort();
 assertThat(sort).isNotNull();
 assertThat(sort.getSort().length).isEqualTo(1);
 assertThat(sort.getSort()[0].getField()).isEqualTo("code");
 assertThat(sort.getSort()[0].getType()).isEqualTo(SortField.Type.LONG);
}
origin: apache/jackrabbit

public Object visit(LowerCaseImpl node, Object data)
    throws Exception {
  SortField sf = (SortField) ((DynamicOperandImpl) node.getOperand()).accept(this, data);
  selectorName[0] = node.getSelectorQName();
  return new SortField(sf.getField(),
      new LowerCaseSortComparator(sf.getComparatorSource()),
      !ordering.isAscending());
}
origin: org.apache.jackrabbit/jackrabbit-core

public Object visit(UpperCaseImpl node, Object data)
    throws Exception {
  SortField sf = (SortField) ((DynamicOperandImpl) node.getOperand()).accept(this, data);
  selectorName[0] = node.getSelectorQName();
  return new SortField(sf.getField(),
      new UpperCaseSortComparator(sf.getComparatorSource()),
      !ordering.isAscending());
}
org.apache.lucene.searchSortFieldgetField

Javadoc

Returns the name of the field. Could return null if the sort is by SCORE or DOC.

Popular methods of SortField

  • <init>
    Creates a sort, possibly in reverse, by terms in the given field where the type of term value is det
  • getReverse
    Returns whether the sort should be reversed.
  • getType
    Returns the type of contents in the field.
  • setMissingValue
    Set the value to use for documents that don't have a value.
  • equals
    Returns true if o is equal to this. If a FieldComparatorSource was provided, it must properly implem
  • getComparator
    Returns the FieldComparator to use for sorting.
  • getComparatorSource
    Returns the FieldComparatorSource used for custom sorting
  • getMissingValue
    Return the value to use for documents that don't have a value. A value of null indicates that defaul
  • toString
  • hashCode
    Returns a hash code for this SortField instance. If a FieldComparatorSource was provided, it must pr
  • needsScores
    Whether the relevance score is needed to sort documents.
  • getFactory
  • needsScores,
  • getFactory,
  • getLocale,
  • initFieldType,
  • rewrite

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • startActivity (Activity)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JTextField (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now