本文整理汇总了Java中org.apache.solr.search.DocIterator.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java DocIterator.hasNext方法的具体用法?Java DocIterator.hasNext怎么用?Java DocIterator.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.search.DocIterator
的用法示例。
在下文中一共展示了DocIterator.hasNext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
@Override
public void transform(SolrDocument doc, int docid) {
FieldType idFt = idField.getType();
Object parentIdField = doc.getFirstValue(idField.getName());
String parentIdExt = parentIdField instanceof IndexableField
? idFt.toExternal((IndexableField)parentIdField)
: parentIdField.toString();
try {
Query parentQuery = idFt.getFieldQuery(null, idField, parentIdExt);
Query query = new ToChildBlockJoinQuery(parentQuery, parentsFilter, false);
DocList children = context.searcher.getDocList(query, childFilterQuery, new Sort(), 0, limit);
if(children.matches() > 0) {
DocIterator i = children.iterator();
while(i.hasNext()) {
Integer childDocNum = i.next();
Document childDoc = context.searcher.doc(childDocNum);
SolrDocument solrChildDoc = ResponseWriterUtil.toSolrDocument(childDoc, schema);
// TODO: future enhancement...
// support an fl local param in the transformer, which is used to build
// a private ReturnFields instance that we use to prune unwanted field
// names from solrChildDoc
doc.addChildDocument(solrChildDoc);
}
}
} catch (IOException e) {
doc.put(name, "Could not fetch child Documents");
}
}
示例2: toDocIDs
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
/** Converts solr's DocList to the int[] docIDs */
protected int[] toDocIDs(DocList docs) {
int[] docIDs = new int[docs.size()];
DocIterator iterator = docs.iterator();
for (int i = 0; i < docIDs.length; i++) {
if (!iterator.hasNext()) {
throw new AssertionError();
}
docIDs[i] = iterator.nextDoc();
}
if (iterator.hasNext()) {
throw new AssertionError();
}
return docIDs;
}
示例3: createDocumentClusters
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
private DblClusters<Document> createDocumentClusters(ResponseBuilder rb, int maxCount, Set<String> fields) throws IOException {
DblClusters<Document> clusters = new DblClusters<>(2, maxCount);
DocSet docSet = rb.getResults().docSet;
DocIterator iterator = docSet.iterator();
while (iterator.hasNext()) {
Integer docId = iterator.next();
Document doc = rb.req.getSearcher().doc(docId, fields);
IndexableField latitudeField = doc.getField(this.fieldNameLat);
IndexableField longitudeField = doc.getField(this.fieldNameLon);
if (latitudeField == null || longitudeField == null) {
continue;
}
String latitudeString = latitudeField.stringValue();
String longitudeString = longitudeField.stringValue();
if (!this.isNumeric(latitudeString) || !this.isNumeric(longitudeString)) {
continue;
}
clusters.add(1, new double[] {Double.valueOf(latitudeString), Double.valueOf(longitudeString)}, doc);
}
return clusters;
}
示例4: shouldElementBeIgnored
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
private boolean shouldElementBeIgnored(long dbId, SolrIndexSearcher solrIndexSearcher, DocSet skippingDocs) throws IOException
{
boolean result = false;
if ((skipDescendantAuxDocsForSpecificTypes && !typesForSkippingDescendantAuxDocs.isEmpty())
|| (skipDescendantAuxDocsForSpecificAspects && !aspectsForSkippingDescendantAuxDocs.isEmpty()))
{
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery(new Term(QueryConstants.FIELD_DBID, NumericEncoder.encode(dbId))), Occur.MUST);
DocSet docSet = solrIndexSearcher.getDocSet(query);
int index = -1;
if (docSet instanceof BitDocSet)
{
BitDocSet source = (BitDocSet) docSet;
OpenBitSet openBitSet = source.getBits();
index = openBitSet.nextSetBit(index + 1);
}
else
{
DocIterator it = docSet.iterator();
if (it.hasNext())
{
index = it.nextDoc();
}
}
result = (-1 != index) && skippingDocs.exists(index);
}
return result;
}
示例5: toTopDocs
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
/** Converts solr's DocList to a lucene TopDocs */
protected TopDocs toTopDocs(DocList docs) {
ScoreDoc[] scoreDocs = new ScoreDoc[docs.size()];
DocIterator iterator = docs.iterator();
for (int i = 0; i < scoreDocs.length; i++) {
if (!iterator.hasNext()) {
throw new AssertionError();
}
scoreDocs[i] = new ScoreDoc(iterator.nextDoc(), Float.NaN);
}
if (iterator.hasNext()) {
throw new AssertionError();
}
return new TopDocs(docs.matches(), scoreDocs, Float.NaN);
}
示例6: restoreTopDocs
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
/**
* restore <code>TopDocs</code> from <code>DocListAndSet</code>
*
* @param results
* @return
*/
private TopDocs restoreTopDocs(DocList docList) {
int idx = 0;
ScoreDoc[] scoreDocs = new ScoreDoc[docList.size()];
DocIterator iterator = docList.iterator();
while (iterator.hasNext()) {
int docId = iterator.nextDoc();
scoreDocs[idx++] = new ScoreDoc(docId, -1);
}
return new TopDocs(docList.matches(), scoreDocs, -1);
}
示例7: getMoreLikeThese
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
NamedList<DocList> getMoreLikeThese(ResponseBuilder rb,
SolrIndexSearcher searcher, DocList docs, int flags) throws IOException {
SolrParams p = rb.req.getParams();
IndexSchema schema = searcher.getSchema();
MoreLikeThisHandler.MoreLikeThisHelper mltHelper = new MoreLikeThisHandler.MoreLikeThisHelper(
p, searcher);
NamedList<DocList> mlt = new SimpleOrderedMap<>();
DocIterator iterator = docs.iterator();
SimpleOrderedMap<Object> dbg = null;
if (rb.isDebug()) {
dbg = new SimpleOrderedMap<>();
}
while (iterator.hasNext()) {
int id = iterator.nextDoc();
int rows = p.getInt(MoreLikeThisParams.DOC_COUNT, 5);
DocListAndSet sim = mltHelper.getMoreLikeThis(id, 0, rows, null, null,
flags);
String name = schema.printableUniqueKey(searcher.doc(id));
mlt.add(name, sim.docList);
if (dbg != null) {
SimpleOrderedMap<Object> docDbg = new SimpleOrderedMap<>();
docDbg.add("rawMLTQuery", mltHelper.getRawMLTQuery().toString());
docDbg
.add("boostedMLTQuery", mltHelper.getBoostedMLTQuery().toString());
docDbg.add("realMLTQuery", mltHelper.getRealMLTQuery().toString());
SimpleOrderedMap<Object> explains = new SimpleOrderedMap<>();
DocIterator mltIte = sim.docList.iterator();
while (mltIte.hasNext()) {
int mltid = mltIte.nextDoc();
String key = schema.printableUniqueKey(searcher.doc(mltid));
explains.add(key,
searcher.explain(mltHelper.getRealMLTQuery(), mltid));
}
docDbg.add("explain", explains);
dbg.add(name, docDbg);
}
}
// add debug information
if (dbg != null) {
rb.addDebugInfo("moreLikeThis", dbg);
}
return mlt;
}
示例8: getMoreLikeThese
import org.apache.solr.search.DocIterator; //导入方法依赖的package包/类
NamedList<DocList> getMoreLikeThese(ResponseBuilder rb,
SolrIndexSearcher searcher, DocList docs, int flags) throws IOException {
SolrParams p = rb.req.getParams();
IndexSchema schema = searcher.getSchema();
MoreLikeThisHandler.MoreLikeThisHelper mltHelper = new MoreLikeThisHandler.MoreLikeThisHelper(
p, searcher);
NamedList<DocList> mlt = new SimpleOrderedMap<DocList>();
DocIterator iterator = docs.iterator();
SimpleOrderedMap<Object> dbg = null;
if (rb.isDebug()) {
dbg = new SimpleOrderedMap<Object>();
}
while (iterator.hasNext()) {
int id = iterator.nextDoc();
int rows = p.getInt(MoreLikeThisParams.DOC_COUNT, 5);
DocListAndSet sim = mltHelper.getMoreLikeThis(id, 0, rows, null, null,
flags);
String name = schema.printableUniqueKey(searcher.doc(id));
mlt.add(name, sim.docList);
if (dbg != null) {
SimpleOrderedMap<Object> docDbg = new SimpleOrderedMap<Object>();
docDbg.add("rawMLTQuery", mltHelper.getRawMLTQuery().toString());
docDbg
.add("boostedMLTQuery", mltHelper.getBoostedMLTQuery().toString());
docDbg.add("realMLTQuery", mltHelper.getRealMLTQuery().toString());
SimpleOrderedMap<Object> explains = new SimpleOrderedMap<Object>();
DocIterator mltIte = sim.docList.iterator();
while (mltIte.hasNext()) {
int mltid = mltIte.nextDoc();
String key = schema.printableUniqueKey(searcher.doc(mltid));
explains.add(key,
searcher.explain(mltHelper.getRealMLTQuery(), mltid));
}
docDbg.add("explain", explains);
dbg.add(name, docDbg);
}
}
// add debug information
if (dbg != null) {
rb.addDebugInfo("moreLikeThis", dbg);
}
return mlt;
}