Tabnine Logo
SortField.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.lucene.search.SortField
constructor

Best Java code snippets using org.apache.lucene.search.SortField.<init> (Showing top 20 results out of 837)

Refine searchRefine arrow

  • Sort.<init>
origin: soabase/exhibitor

public TopDocs   search(Query query, int maxResults) throws IOException
{
  Sort sort = new Sort(new SortField(FieldNames.DATE, SortField.LONG, true));
  return searcher.search(query, maxResults, sort);
}
origin: querydsl/querydsl

  public Sort toSort(List<? extends OrderSpecifier<?>> orderBys) {
    List<SortField> sorts = new ArrayList<SortField>(orderBys.size());
    for (OrderSpecifier<?> order : orderBys) {
      if (!(order.getTarget() instanceof Path<?>)) {
        throw new IllegalArgumentException("argument was not of type Path.");
      }
      Class<?> type = order.getTarget().getType();
      boolean reverse = !order.isAscending();
      Path<?> path = getPath(order.getTarget());
      if (Number.class.isAssignableFrom(type)) {
        sorts.add(new SortField(toField(path), sortFields.get(type), reverse));
      } else {
        sorts.add(new SortField(toField(path), SortField.Type.STRING, reverse));
      }
    }
    Sort sort = new Sort();
    sort.setSort(sorts.toArray(new SortField[sorts.size()]));
    return sort;
  }
}
origin: querydsl/querydsl

  public Sort toSort(List<? extends OrderSpecifier<?>> orderBys) {
    List<SortField> sorts = new ArrayList<SortField>(orderBys.size());
    for (OrderSpecifier<?> order : orderBys) {
      if (!(order.getTarget() instanceof Path<?>)) {
        throw new IllegalArgumentException("argument was not of type Path.");
      }
      Class<?> type = order.getTarget().getType();
      boolean reverse = !order.isAscending();
      Path<?> path = getPath(order.getTarget());
      if (Number.class.isAssignableFrom(type)) {
        sorts.add(new SortField(toField(path), sortFields.get(type), reverse));
      } else {
        sorts.add(new SortField(toField(path), sortLocale, reverse));
      }
    }
    Sort sort = new Sort();
    sort.setSort(sorts.toArray(new SortField[sorts.size()]));
    return sort;
  }
}
origin: querydsl/querydsl

  public Sort toSort(List<? extends OrderSpecifier<?>> orderBys) {
    List<SortField> sorts = new ArrayList<SortField>(orderBys.size());
    for (OrderSpecifier<?> order : orderBys) {
      if (!(order.getTarget() instanceof Path<?>)) {
        throw new IllegalArgumentException(
            "argument was not of type Path.");
      }
      Class<?> type = order.getTarget().getType();
      boolean reverse = !order.isAscending();
      Path<?> path = getPath(order.getTarget());
      if (Number.class.isAssignableFrom(type)) {
        sorts.add(new SortedNumericSortField(toField(path), sortFields.get(type),
            reverse));
      } else {
        sorts.add(new SortField(toField(path), SortField.Type.STRING,
            reverse));
      }
    }
    Sort sort = new Sort();
    sort.setSort(sorts.toArray(new SortField[sorts.size()]));
    return sort;
  }
}
origin: oracle/opengrok

  sort = new Sort(new SortField(QueryBuilder.DATE, SortField.Type.STRING, true));
  break;
case BY_PATH:
  sort = new Sort(new SortField(QueryBuilder.FULLPATH, SortField.Type.STRING));
  break;
default:
origin: oracle/opengrok

SortField sfield = new SortField(QueryBuilder.DATE, SortField.Type.STRING, true);
Sort sort = new Sort(sfield);
QueryParser qparser = new QueryParser(QueryBuilder.PATH, new CompatibleAnalyser());
Query query;
origin: neo4j/neo4j

@Test
void shouldReturnDocValuesInGivenOrder() throws Exception
{
  // given
  DocValuesCollector collector = new DocValuesCollector( false );
  IndexReaderStub readerStub = indexReaderWithMaxDocs( 42 );
  // when
  collector.doSetNextReader( readerStub.getContext() );
  collector.collect( 1 );
  collector.collect( 2 );
  // then
  Sort byIdDescending = new Sort( new SortField( "id", SortField.Type.LONG, true ) );
  LongIterator valuesIterator = collector.getSortedValuesIterator( "id", byIdDescending );
  assertEquals( 2, valuesIterator.next() );
  assertEquals( 1, valuesIterator.next() );
  assertFalse( valuesIterator.hasNext() );
}
origin: neo4j/neo4j

@Test
void shouldReturnIndexHitsInGivenSortOrder() throws Exception
{
  // given
  DocValuesCollector collector = new DocValuesCollector( false );
  IndexReaderStub readerStub = indexReaderWithMaxDocs( 43 );
  // when
  collector.doSetNextReader( readerStub.getContext() );
  collector.collect( 1 );
  collector.collect( 3 );
  collector.collect( 37 );
  collector.collect( 42 );
  // then
  Sort byIdDescending = new Sort( new SortField( "id", SortField.Type.LONG, true ) );
  IndexHits<Document> indexHits = collector.getIndexHits( byIdDescending );
  assertEquals( 4, indexHits.size() );
  assertEquals( "42", indexHits.next().get( "id" ) );
  assertEquals( "37", indexHits.next().get( "id" ) );
  assertEquals( "3", indexHits.next().get( "id" ) );
  assertEquals( "1", indexHits.next().get( "id" ) );
  assertFalse( indexHits.hasNext() );
}
origin: org.elasticsearch/elasticsearch

private TopDocs searchOperations(ScoreDoc after) throws IOException {
  final Query rangeQuery = LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, Math.max(fromSeqNo, lastSeenSeqNo), toSeqNo);
  final Sort sortedBySeqNoThenByTerm = new Sort(
    new SortField(SeqNoFieldMapper.NAME, SortField.Type.LONG),
    new SortField(SeqNoFieldMapper.PRIMARY_TERM_NAME, SortField.Type.LONG, true)
  );
  return indexSearcher.searchAfter(after, rangeQuery, searchBatchSize, sortedBySeqNoThenByTerm);
}
origin: rnewson/couchdb-lucene

public static Sort toSort(final String sort) throws ParseException {
  if (sort == null) {
    return null;
  } else {
    final String[] split = sort.split(",");
    final SortField[] sort_fields = new SortField[split.length];
    for (int i = 0; i < split.length; i++) {
      String tmp = split[i];
      final boolean reverse = tmp.charAt(0) == '\\';
      // Strip sort order character.
      if (tmp.charAt(0) == '\\' || tmp.charAt(0) == '/') {
        tmp = tmp.substring(1);
      }
      final SortField sortField;
      if ("_score".equals(tmp)) {
        sortField = new SortField(null, SortField.Type.SCORE, reverse);
      } else if ("_doc".equals(tmp)) {
        sortField = new SortField(null, SortField.Type.DOC, reverse);
      } else {
        final TypedField typedField = new TypedField(tmp);
        sortField = new SortField(typedField.getName(), typedField
            .toSortField(), reverse);
      }
      sort_fields[i] = sortField;
    }
    return new Sort(sort_fields);
  }
}
origin: org.apache.lucene/lucene-core

   sortFields[i] = new SortedNumericSortField(fieldName, sortType, reverse, sortedNumericSelector);
  } else {
   sortFields[i] = new SortField(fieldName, sortType, reverse);
 indexSort = new Sort(sortFields);
} else if (numSortFields < 0) {
 throw new CorruptIndexException("invalid index sort field count: " + numSortFields, input);
origin: org.apache.lucene/lucene-core

   sortFields[i] = new SortedNumericSortField(fieldName, sortType, reverse, sortedNumericSelector);
  } else {
   sortFields[i] = new SortField(fieldName, sortType, reverse);
 indexSort = new Sort(sortFields);
} else if (numSortFields < 0) {
 throw new CorruptIndexException("invalid index sort field count: " + numSortFields, input);
origin: sanluan/PublicCMS

Sort sort = new Sort(new SortField("publishDate", SortField.Type.LONG, true));
query.setSort(sort);
origin: sanluan/PublicCMS

Sort sort = new Sort(new SortField("publishDate", SortField.Type.LONG, true));
query.setSort(sort);
origin: sanluan/PublicCMS

Sort sort = new Sort(new SortField("publishDate", SortField.Type.LONG, true));
query.setSort(sort);
origin: sanluan/PublicCMS

Sort sort = new Sort(new SortField("publishDate", SortField.Type.LONG, true));
query.setSort(sort);
origin: org.pageseeder.flint/pso-flint-lucene

/**
 * Creates new predicate search query.
 *
 * @param predicate The predicate for this query.
 * @param analyzer  The analyzer to use for the query, should be the same as the one used to write the Index.
 * @param sortField The field name to use to order the results.
 *
 * @throws IllegalArgumentException If the predicate is <code>null</code>.
 */
public PredicateSearchQuery(String predicate, Analyzer analyzer, String sortField) throws IllegalArgumentException {
 this(predicate, analyzer, sortField == null ? Sort.INDEXORDER : new Sort(new SortField(sortField, Type.STRING)));
}
origin: org.kie.workbench.screens/kie-wb-common-library-backend

@Override
public Sort getSortOrder() {
  return new Sort(new SortField(FieldFactory.FILE_NAME_FIELD_SORTED,
                 SortField.Type.STRING));
}
origin: org.pageseeder.flint/pso-flint-lucene

/**
 * Creates new predicate search query.
 *
 * @param predicate The predicate for this query.
 * @param sortField The field name to use to order the results.
 *
 * @throws IllegalArgumentException If the predicate is <code>null</code>.
 */
public PredicateSearchQuery(String predicate, String sortField) throws IllegalArgumentException {
 this(predicate, sortField == null ? Sort.INDEXORDER : new Sort(new SortField(sortField, Type.STRING)));
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

private TopDocs searchOperations(ScoreDoc after) throws IOException {
  final Query rangeQuery = LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, Math.max(fromSeqNo, lastSeenSeqNo), toSeqNo);
  final Sort sortedBySeqNoThenByTerm = new Sort(
    new SortField(SeqNoFieldMapper.NAME, SortField.Type.LONG),
    new SortField(SeqNoFieldMapper.PRIMARY_TERM_NAME, SortField.Type.LONG, true)
  );
  return indexSearcher.searchAfter(after, rangeQuery, searchBatchSize, sortedBySeqNoThenByTerm);
}
org.apache.lucene.searchSortField<init>

Javadoc

Creates a sort by terms in the given field where the type of term value is determined dynamically ( #AUTO).

Popular methods of SortField

  • 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.
  • 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

  • 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
  • Best IntelliJ plugins
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