• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: sortField

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


示例17: sortField

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


示例18: testRandomFieldNameSorts

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
public void testRandomFieldNameSorts() throws Exception {
  SolrQueryRequest req = lrf.makeRequest("q", "*:*");

  final int iters = atLeast(5000);

  // infinite loop abort when trying to generate a non-blank sort "name"
  final int nonBlankAttempts = 37;

  for (int i = 0; i < iters; i++) {
    final StringBuilder input = new StringBuilder();
    final String[] names = new String[_TestUtil.nextInt(r,1,10)];
    final boolean[] reverse = new boolean[names.length];
    for (int j = 0; j < names.length; j++) {
      names[j] = null;
      for (int k = 0; k < nonBlankAttempts && null == names[j]; k++) {
        names[j] = _TestUtil.randomRealisticUnicodeString(r, 1, 100);

        // munge anything that might make this a function
        names[j] = names[j].replaceFirst("\\{","\\{\\{");
        names[j] = names[j].replaceFirst("\\(","\\(\\(");
        names[j] = names[j].replaceFirst("(\\\"|\\')","$1$1z");
        names[j] = names[j].replaceFirst("(\\d)","$1x");

        // eliminate pesky problem chars
        names[j] = names[j].replaceAll("\\p{Cntrl}|\\p{javaWhitespace}","");
        
        if (0 == names[j].length()) {
          names[j] = null;
        }
      }
      // with luck this bad, never go to vegas
      // alternatively: if (null == names[j]) names[j] = "never_go_to_vegas";
      assertNotNull("Unable to generate a (non-blank) names["+j+"] after "
                    + nonBlankAttempts + " attempts", names[j]);

      reverse[j] = r.nextBoolean();

      input.append(r.nextBoolean() ? " " : "");
      input.append(names[j]);
      input.append(" ");
      input.append(reverse[j] ? "desc," : "asc,");
    }
    input.deleteCharAt(input.length()-1);
    SortField[] sorts = null;
    try {
      sorts = QueryParsing.parseSort(input.toString(), req).getSort();
    } catch (RuntimeException e) {
      throw new RuntimeException("Failed to parse sort: " + input, e);
    }
    assertEquals("parsed sorts had unexpected size", 
                 names.length, sorts.length);
    for (int j = 0; j < names.length; j++) {
      assertEquals("sorts["+j+"] had unexpected reverse: " + input,
                   reverse[j], sorts[j].getReverse());

      final Type type = sorts[j].getType();

      if (Type.SCORE.equals(type)) {
        assertEquals("sorts["+j+"] is (unexpectedly) type score : " + input,
                     "score", names[j]);
      } else if (Type.DOC.equals(type)) {
        assertEquals("sorts["+j+"] is (unexpectedly) type doc : " + input,
                     "_docid_", names[j]);
      } else if (Type.CUSTOM.equals(type) || Type.REWRITEABLE.equals(type)) {

        fail("sorts["+j+"] resulted in a '" + type.toString()
             + "', either sort parsing code is broken, or func/query " 
             + "semantics have gotten broader and munging in this test "
             + "needs improved: " + input);

      } else {
        assertEquals("sorts["+j+"] ("+type.toString()+
                     ") had unexpected field in: " + input,
                     names[j], sorts[j].getField());
      }
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:79,代码来源:TestSort.java


示例19: Lucene

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
Lucene(Type fieldType) {
	this.fieldType = fieldType;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:4,代码来源:TicketIndexer.java


示例20: ESortField

import org.apache.lucene.search.SortField.Type; //导入依赖的package包/类
/**
 * Creates a new instance with all properties.
 * @param id the id of the {@link ESortField}.
 * @param name the name of the {@link Field} in the {@link News} {@link Document} to which
 * 			will be sorted.
 * @param type the {@link Type} of the field set in {@link #name()}.
 * @param defaultOrder the default {@link ESortOrder} for this field.
 */
private ESortField(final int id, final String name, final Type type, final ESortOrder defaultOrder) {
	this.id = id;
	this.name = name;
	this.type = type;
	this.defaultOrder = defaultOrder;
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:15,代码来源:NewsDao.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Engine类代码示例发布时间:2022-05-21
下一篇:
Java Transaction类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap