Codota Logo
SortField.getType
Code IndexAdd Codota 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)

  • Common ways to obtain SortField
private void myMethod () {
SortField s =
  • Codota IconString field;SortField.Type type;new SortField(field, type, reverse)
  • Codota IconSort sort;sort.getSort()
  • Codota IconIndexSearcher searcher;fields[i].rewrite(searcher)
  • Smart code suggestions by Codota
}
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

  • Start an intent from android
  • getSystemService (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • requestLocationUpdates (LocationManager)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now