当前位置: 首页>>代码示例>>Java>>正文


Java Type类代码示例

本文整理汇总了Java中org.apache.lucene.search.SortField.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Type类属于org.apache.lucene.search.SortField包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToSort

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
Sort convertToSort(JsonArray sortKeys) {
    if (sortKeys == null || sortKeys.size() == 0)
        return null;
    SortField[] sortFields = new SortField[sortKeys.size()];
    for (int i = 0; i < sortKeys.size(); i++) {
        JsonObject sortKey = sortKeys.getJsonObject(i);
        String sortBy = sortKey.getString("sortBy");
        boolean sortDescending = sortKey.getBoolean("sortDescending", false);
        String core = sortKey.getString("core", null);
        SortField field;
        if (sortBy.equals(SORT_ON_SCORE))
            field = new SortField(null, SortField.Type.SCORE, !sortDescending);
        else {
            Type type = typeForSortField(sortKey.getString("type"));
            if (core == null || core.equals(coreName))
                field = new SortField(sortBy, type, sortDescending);
            else
                field = new JoinSortField(sortBy, type, sortDescending, core);
            Object missingValue = missingSortValue(sortKey, type);
            if (missingValue != null)
                field.setMissingValue(missingValue);
        }
        sortFields[i] = field;
    }
    return new Sort(sortFields);
}
 
开发者ID:seecr,项目名称:meresco-lucene,代码行数:27,代码来源:JsonQueryConverter.java

示例2: missingSortValue

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
private Object missingSortValue(JsonObject sortKey, Type type) {
    JsonValue missingValue = sortKey.getOrDefault("missingValue", null);
    if (missingValue == null)
        return null;
    if (missingValue instanceof JsonString) {
        if (((JsonString) missingValue).getString().equals("STRING_FIRST"))
            return SortField.STRING_FIRST;
        else if (((JsonString) missingValue).getString().equals("STRING_LAST"))
            return SortField.STRING_LAST;
    } else {
        switch (type) {
            case INT:
                return ((JsonNumber) missingValue).intValue();
            case LONG:
                return ((JsonNumber) missingValue).longValue();
            case DOUBLE:
                return ((JsonNumber) missingValue).doubleValue();
            default:
                break;
        }
    }
    return null;
}
 
开发者ID:seecr,项目名称:meresco-lucene,代码行数:24,代码来源:JsonQueryConverter.java

示例3: browseAllDocs

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
/**
    * Finds the top n hits from whole Index where all results are after a
    * previous result (after)
    * 
    * @param after
    *            the last doc from previous search
    * @param nDocs
    *            nb of elements to retrieve in total
    * @return
    */
   public BrowseAllDocsResponse browseAllDocs(ScoreDoc after, int nDocs) {
List<String> listOfDocReferences = new ArrayList<String>();
IndexSearcher searcher = null;
try {
    searcher = iaviewSearcherManager.acquire();

    TopDocs topDocs = searcher.searchAfter(after, new MatchAllDocsQuery(), nDocs, new Sort(new SortField(null,
	    Type.DOC)));
    ScoreDoc scoreDoc = null;
    for (int i = 0; i < topDocs.scoreDocs.length; i++) {
	scoreDoc = topDocs.scoreDocs[i];
	Document document = searcher.doc(scoreDoc.doc,
		new HashSet<String>(Arrays.asList(InformationAssetViewFields.DOCREFERENCE.toString())));
	String docReferenceFromLuceneDocument = LuceneTaxonomyMapper
		.getDocReferenceFromLuceneDocument(document);

	listOfDocReferences.add(docReferenceFromLuceneDocument);
    }
    return new BrowseAllDocsResponse(listOfDocReferences, scoreDoc);

} catch (IOException ioException) {
    throw new TaxonomyException(TaxonomyErrorType.LUCENE_IO_EXCEPTION, ioException);
} finally {
    LuceneHelperTools.releaseSearcherManagerQuietly(iaviewSearcherManager, searcher);
}
   }
 
开发者ID:nationalarchives,项目名称:taxonomy,代码行数:37,代码来源:IAViewRepository.java

示例4: getSortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
@Override
public SortField getSortField(boolean reverse) {
  if (reverse) {
    return new SortField(getFieldName(), Type.LONG, reverse);
  }
  return new SortField(getFieldName(), Type.LONG);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:8,代码来源:DateFieldTypeDefinition.java

示例5: getSortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
@Override
public SortField getSortField(boolean reverse) {
  if (reverse) {
    return new SortField(getFieldName(), Type.STRING, reverse);
  }
  return new SortField(getFieldName(), Type.STRING);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:8,代码来源:StringFieldTypeDefinition.java

示例6: getSortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
@Override
public SortField getSortField(boolean reverse) {
  if (reverse) {
    return new SortField(getFieldName(), Type.DOUBLE, reverse);
  }
  return new SortField(getFieldName(), Type.DOUBLE);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:8,代码来源:DoubleFieldTypeDefinition.java

示例7: getSortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
@Override
public SortField getSortField(boolean reverse) {
  if (reverse) {
    return new SortField(getFieldName(), Type.INT, reverse);
  }
  return new SortField(getFieldName(), Type.INT);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:8,代码来源:IntFieldTypeDefinition.java

示例8: getSortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
@Override
public SortField getSortField(boolean reverse) {
  if (reverse) {
    return new SortField(getFieldName(), Type.FLOAT, reverse);
  }
  return new SortField(getFieldName(), Type.FLOAT);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:8,代码来源:FloatFieldTypeDefinition.java

示例9: testSimpleSearchPagingWithSorting

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
@Test
public void testSimpleSearchPagingWithSorting() throws Exception {
  IndexReader reader = getReaderFlatScore(length);
  IndexSearcherCloseable searcher = getSearcher(reader);

  TotalHitsRef totalHitsRef = new TotalHitsRef();
  ProgressRef progressRef = new ProgressRef();

  printHeapSize();
  TermQuery query = new TermQuery(new Term("f1", "value"));
  Sort sort = new Sort(new SortField("index", Type.INT, true));
  IterablePaging paging = new IterablePaging(new AtomicBoolean(true), searcher, query, 100, null, null, false, sort,
      new DeepPagingCache());
  IterablePaging itPaging = paging.skipTo(90).gather(20).totalHits(totalHitsRef).progress(progressRef);
  BlurIterator<ScoreDoc, BlurException> iterator = itPaging.iterator();
  int position = 90;
  int searches = 1;
  while (iterator.hasNext()) {
    ScoreDoc sd = iterator.next();
    assertEquals(position, progressRef.currentHitPosition());
    assertEquals(searches, progressRef.searchesPerformed());
    System.out.println("time [" + progressRef.queryTime() + "] " + "total hits [" + totalHitsRef.totalHits() + "] "
        + "searches [" + progressRef.searchesPerformed() + "] " + "position [" + progressRef.currentHitPosition()
        + "] " + "doc id [" + sd.doc + "] " + "score [" + sd.score + "]");
    position++;
    if (position == 100) {
      searches++;
    }
  }
  printHeapSize();
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:32,代码来源:TestingPagingCollector.java

示例10: getComparator

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
public FieldComparator<?> getComparator(String field, Type type, boolean reverse, final int numHits, final int sortPos, Object missingValue) {
    switch(type) {
        case STRING:
            return new JoinTermOrdValComparator(numHits, field, missingValue == SortField.STRING_LAST, this);
        case INT:
            return new JoinIntComparator(numHits, field, (Integer) missingValue, this);
        case DOUBLE:
            return new JoinDoubleComparator(numHits, field, (Double) missingValue, this);
        default:
            throw new IllegalStateException("Illegal join sort type: " + type);
    }
}
 
开发者ID:seecr,项目名称:meresco-lucene,代码行数:13,代码来源:JoinSortCollector.java

示例11: typeForSortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
private SortField.Type typeForSortField(String type) {
    switch (type) {
        case "String":
            return SortField.Type.STRING;
        case "Int":
            return SortField.Type.INT;
        case "Double":
            return SortField.Type.DOUBLE;
        case "Long":
            return SortField.Type.LONG;
    }
    return null;
}
 
开发者ID:seecr,项目名称:meresco-lucene,代码行数:14,代码来源:JsonQueryConverter.java

示例12: testEmptyIndex

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
@Test
public void testEmptyIndex() throws Exception {
  // LUCENE-5045: make sure DrillSideways works with an empty index
  Directory dir = newDirectory();
  Directory taxoDir = newDirectory();
  writer = new RandomIndexWriter(random(), dir);
  taxoWriter = new DirectoryTaxonomyWriter(taxoDir, IndexWriterConfig.OpenMode.CREATE);
  IndexSearcher searcher = newSearcher(writer.getReader());
  writer.close();
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
  taxoWriter.close();

  // Count "Author"
  FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));

  DrillSideways ds = new DrillSideways(searcher, taxoReader);
  DrillDownQuery ddq = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
  ddq.add(new CategoryPath("Author", "Lisa"));
  
  DrillSidewaysResult r = ds.search(null, ddq, 10, fsp); // this used to fail on IllegalArgEx
  assertEquals(0, r.hits.totalHits);

  r = ds.search(ddq, null, null, 10, new Sort(new SortField("foo", Type.INT)), false, false, fsp); // this used to fail on IllegalArgEx
  assertEquals(0, r.hits.totalHits);
  
  IOUtils.close(searcher.getIndexReader(), taxoReader, dir, taxoDir);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:28,代码来源:TestDrillSideways.java

示例13: sortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public SortField sortField(String field, boolean reverse) {
    return new SortField(field, Type.LONG, reverse);
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:6,代码来源:GeoShapeMapper.java

示例14: sortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public SortField sortField(String field, boolean reverse) {
    return new SortField(field, Type.STRING, reverse);
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:6,代码来源:ColumnMapperBlob.java

示例15: sortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public SortField sortField(String field, boolean reverse) {
    return new SortField(field, Type.FLOAT, reverse);
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:6,代码来源:ColumnMapperFloat.java


注:本文中的org.apache.lucene.search.SortField.Type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。