Tabnine Logo
SortField.getType
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: org.apache.lucene/lucene-core

/** Returns the native sort type for {@link SortedSetSortField} and {@link SortedNumericSortField},
 * {@link SortField#getType()} otherwise */
static SortField.Type getSortFieldType(SortField sortField) {
 if (sortField instanceof SortedSetSortField) {
  return SortField.Type.STRING;
 } else if (sortField instanceof SortedNumericSortField) {
  return ((SortedNumericSortField) sortField).getNumericType();
 } else {
  return sortField.getType();
 }
}
origin: org.apache.lucene/lucene-core

switch (dvType) {
 case NUMERIC:
  if (sortField.getType().equals(SortField.Type.INT) == false &&
     sortField.getType().equals(SortField.Type.LONG) == false &&
     sortField.getType().equals(SortField.Type.FLOAT) == false &&
     sortField.getType().equals(SortField.Type.DOUBLE) == false) {
   throw new IllegalArgumentException("invalid doc value type:" + dvType + " for sortField:" + sortField);
  if (sortField.getType().equals(SortField.Type.STRING) == false) {
   throw new IllegalArgumentException("invalid doc value type:" + dvType + " for sortField:" + sortField);
origin: org.apache.lucene/lucene-core

throw new IllegalArgumentException("unhandled SortField.getType()=" + sortField.getType());
origin: org.apache.lucene/lucene-core

@Override
Sorter.DocComparator getDocComparator(int maxDoc, SortField sortField) throws IOException {
 assert sortField.getType().equals(SortField.Type.STRING);
 assert finalSortedValues == null && finalOrdMap == null &&finalOrds == null;
 int valueCount = hash.size();
 finalSortedValues = hash.sort();
 finalOrds = pending.build();
 finalOrdMap = new int[valueCount];
 for (int ord = 0; ord < valueCount; ord++) {
  finalOrdMap[finalSortedValues[ord]] = ord;
 }
 final SortedDocValues docValues =
   new BufferedSortedDocValues(hash, valueCount, finalOrds, finalSortedValues, finalOrdMap,
     docsWithField.iterator());
 return Sorter.getDocComparator(maxDoc, sortField, () -> docValues, () -> null);
}
origin: org.apache.lucene/lucene-core

throw new IllegalArgumentException("unhandled SortField.getType()=" + sortField.getType());
origin: org.apache.lucene/lucene-core

for (int i = 0; i < numSortFields; ++i) {
 SortField sortField = indexSort.getSort()[i];
 SortField.Type sortType = sortField.getType();
 output.writeString(sortField.getField());
 int sortTypeID;
 switch (sortField.getType()) {
  case STRING:
   sortTypeID = 0;
   throw new IllegalStateException("Unexpected sort type: " + sortField.getType());
   break;
  default:
   throw new IllegalStateException("Unexpected sort type: " + sortField.getType());
origin: org.elasticsearch/elasticsearch

  public static SortField.Type getSortFieldType(SortField sortField) {
    if (sortField instanceof SortedSetSortField) {
      return SortField.Type.STRING;
    } else if (sortField instanceof SortedNumericSortField) {
      return ((SortedNumericSortField) sortField).getNumericType();
    } else {
      return sortField.getType();
    }
  }
}
origin: rnewson/couchdb-lucene

switch (field.getType()) {
  case DOC:
    type = "doc";
origin: org.elasticsearch/elasticsearch

public static Optional<SortAndFormats> buildSort(List<SortBuilder<?>> sortBuilders, QueryShardContext context) throws IOException {
  List<SortField> sortFields = new ArrayList<>(sortBuilders.size());
  List<DocValueFormat> sortFormats = new ArrayList<>(sortBuilders.size());
  for (SortBuilder<?> builder : sortBuilders) {
    SortFieldAndFormat sf = builder.build(context);
    sortFields.add(sf.field);
    sortFormats.add(sf.format);
  }
  if (!sortFields.isEmpty()) {
    // optimize if we just sort on score non reversed, we don't really
    // need sorting
    boolean sort;
    if (sortFields.size() > 1) {
      sort = true;
    } else {
      SortField sortField = sortFields.get(0);
      if (sortField.getType() == SortField.Type.SCORE && !sortField.getReverse()) {
        sort = false;
      } else {
        sort = true;
      }
    }
    if (sort) {
      return Optional.of(new SortAndFormats(
          new Sort(sortFields.toArray(new SortField[sortFields.size()])),
          sortFormats.toArray(new DocValueFormat[sortFormats.size()])));
    }
  }
  return Optional.empty();
}
origin: org.elasticsearch/elasticsearch

/**
 * Returns the inner {@link SortField.Type} expected for this sort field.
 */
static SortField.Type extractSortType(SortField sortField) {
  if (sortField.getComparatorSource() instanceof IndexFieldData.XFieldComparatorSource) {
    return ((IndexFieldData.XFieldComparatorSource) sortField.getComparatorSource()).reducedType();
  } else if (sortField instanceof SortedSetSortField) {
    return SortField.Type.STRING;
  } else if (sortField instanceof SortedNumericSortField) {
    return ((SortedNumericSortField) sortField).getNumericType();
  } else if ("LatLonPointSortField".equals(sortField.getClass().getSimpleName())) {
    // for geo distance sorting
    return SortField.Type.DOUBLE;
  } else {
    return sortField.getType();
  }
}
origin: org.elasticsearch/elasticsearch

for (int index = 0; index < sort.getSort().length; index++) {
  SortField sortField = sort.getSort()[index];
  if (sortField.getType() == SCORE) {
    scorePos = index;
    break;
origin: org.elasticsearch/elasticsearch

sortFields = fieldDocs.fields;
if (fieldDocs instanceof CollapseTopFieldDocs) {
  isSortedByField = (fieldDocs.fields.length == 1 && fieldDocs.fields[0].getType() == SortField.Type.SCORE) == false;
  CollapseTopFieldDocs collapseTopFieldDocs = (CollapseTopFieldDocs) fieldDocs;
  collapseField = collapseTopFieldDocs.field;
origin: org.elasticsearch/elasticsearch

SortField[] sortFields = sortedTopDocs.sortFields;
for (int i = 0; i < sortFields.length; i++) {
  if (sortFields[i].getType() == SortField.Type.SCORE) {
    sortScoreIndex = i;
origin: org.elasticsearch/elasticsearch

  writeMissingValue(out, comparatorSource.missingValue(sortField.getReverse()));
} else {
  writeSortType(out, sortField.getType());
  writeMissingValue(out, sortField.getMissingValue());
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/** Returns the native sort type for {@link SortedSetSortField} and {@link SortedNumericSortField},
 * {@link SortField#getType()} otherwise */
static SortField.Type getSortFieldType(SortField sortField) {
 if (sortField instanceof SortedSetSortField) {
  return SortField.Type.STRING;
 } else if (sortField instanceof SortedNumericSortField) {
  return ((SortedNumericSortField) sortField).getNumericType();
 } else {
  return sortField.getType();
 }
}
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: 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 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: 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);
}
org.apache.lucene.searchSortFieldgetType

Javadoc

Returns the type of contents in the field.

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
  • getField
    Returns the name of the field. Could return null if the sort is by SCORE or DOC.
  • getReverse
    Returns whether the sort should be reversed.
  • 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

  • Creating JSON documents from java classes using gson
  • addToBackStack (FragmentTransaction)
  • setScale (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Collectors (java.util.stream)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top plugins for WebStorm
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