本文整理汇总了Java中org.apache.solr.search.DocSet类的典型用法代码示例。如果您正苦于以下问题:Java DocSet类的具体用法?Java DocSet怎么用?Java DocSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocSet类属于org.apache.solr.search包,在下文中一共展示了DocSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ParsedParams
import org.apache.solr.search.DocSet; //导入依赖的package包/类
public ParsedParams(final SolrParams localParams, // localParams on this particular facet command
final SolrParams params, // local+original
final SolrParams required, // required version of params
final String facetValue, // the field to or query to facet on (minus local params)
final DocSet docs, // the base docset for this particular facet
final String key, // what name should the results be stored under
final List<String> tags,
final int threads) {
this.localParams = localParams;
this.params = params;
this.required = required;
this.facetValue = facetValue;
this.docs = docs;
this.key = key;
this.tags = tags;
this.threads = threads;
}
示例2: getGroupedFacetQueryCount
import org.apache.solr.search.DocSet; //导入依赖的package包/类
/**
* Returns a grouped facet count for the facet query
*
* @see FacetParams#FACET_QUERY
*/
public int getGroupedFacetQueryCount(Query facetQuery, DocSet docSet) throws IOException {
// It is okay to retrieve group.field from global because it is never a local param
String groupField = global.get(GroupParams.GROUP_FIELD);
if (groupField == null) {
throw new SolrException (
SolrException.ErrorCode.BAD_REQUEST,
"Specify the group.field as parameter or local parameter"
);
}
TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
Filter mainQueryFilter = docSet.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
Query filteredFacetQuery = new BooleanQuery.Builder()
.add(facetQuery, Occur.MUST)
.add(mainQueryFilter, Occur.FILTER)
.build();
searcher.search(filteredFacetQuery, collector);
return collector.getGroupCount();
}
示例3: doSimpleQuery
import org.apache.solr.search.DocSet; //导入依赖的package包/类
/**
* Executes a basic query
*/
public static DocList doSimpleQuery(String sreq,
SolrQueryRequest req,
int start, int limit) throws IOException {
List<String> commands = StrUtils.splitSmart(sreq,';');
String qs = commands.size() >= 1 ? commands.get(0) : "";
try {
Query query = QParser.getParser(qs, null, req).getQuery();
// If the first non-query, non-filter command is a simple sort on an indexed field, then
// we can use the Lucene sort ability.
Sort sort = null;
if (commands.size() >= 2) {
sort = QueryParsing.parseSortSpec(commands.get(1), req).getSort();
}
DocList results = req.getSearcher().getDocList(query,(DocSet)null, sort, start, limit);
return results;
} catch (SyntaxError e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Error parsing query: " + qs);
}
}
示例4: getTermCounts
import org.apache.solr.search.DocSet; //导入依赖的package包/类
private NamedList<Integer> getTermCounts(String field, String fieldPath, Integer mincount, int limit, DocSet docs) throws IOException {
if(cachedFieldCounts.containsKey(fieldPath)){
return cachedFieldCounts.get(fieldPath);
}
int offset = 0;
if (limit == 0) return new NamedList<Integer>();
String sort = FacetParams.FACET_SORT_COUNT;
NamedList<Integer> counts;
FacetMethod method = getFacetMethod(field);
switch (method) {
case ENUM:
// intersectsCheck should be false, else facet counts will be capped at 1 (binary)
counts = getFacetTermEnumCounts(searcher, docs, field, offset, limit, mincount,false,sort,null, null, false, false);
break;
case FC:
counts = DocValuesFacets.getCounts(searcher, docs, field, offset, limit, mincount, false, sort, null, null, false, null);
break;
default:
throw new AssertionError();
}
cachedFieldCounts.put(fieldPath, counts);
return counts;
}
示例5: printDocIDs
import org.apache.solr.search.DocSet; //导入依赖的package包/类
@SuppressWarnings("unused")
private void printDocIDs(DocSet fromSet) throws IOException {
// Only used in debugging.
System.out.println("---------------------------");
DocIterator iter = fromSet.iterator();
while (iter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
Integer docId = iter.next();
Document d = fromSearcher.doc(docId);
String id = d.getValues("id")[0];
// TODO :log message (this is too verbose?)
if (debug) {
System.out.println("INTERNAL ID : " + docId + " DOC : " + id);
}
}
System.out.println("---------------------------");
}
示例6: create
import org.apache.solr.search.DocSet; //导入依赖的package包/类
/**
* Factory method used to create {@link SolrCachingPathScorer} instances.
* @param acceptDocs
*/
public static SolrCachingPathScorer create(SolrCachingPathWeight weight,
AtomicReaderContext context,
Bits acceptDocs, SolrIndexSearcher searcher,
SolrPathQuery wrappedPathQuery) throws IOException
{
DocSet results = (DocSet) searcher.cacheLookup(CacheConstants.ALFRESCO_PATH_CACHE, wrappedPathQuery);
if (results == null)
{
// Cache miss: get path query results and cache them
WrappedQuery wrapped = new WrappedQuery(wrappedPathQuery);
wrapped.setCache(false);
results = searcher.getDocSet(wrapped);
searcher.cacheInsert(CacheConstants.ALFRESCO_PATH_CACHE, wrappedPathQuery, results);
}
return new SolrCachingPathScorer(weight, results, context, acceptDocs, searcher);
}
示例7: AbstractSolrCachingScorer
import org.apache.solr.search.DocSet; //导入依赖的package包/类
AbstractSolrCachingScorer(Weight weight, DocSet in, AtomicReaderContext context, Bits acceptDocs, SolrIndexSearcher searcher)
{
super(weight);
this.context = context;
this.acceptDocs = acceptDocs;
if (in instanceof BitDocSet)
{
matches = (BitDocSet) in;
}
else
{
this.matches = new BitDocSet(new FixedBitSet(searcher.maxDoc()));
for (DocIterator it = in.iterator(); it.hasNext(); /* */)
{
matches.addUnique(it.nextDoc());
}
}
bitSet = matches.getBits();
doc = getBase() - 1;
}
示例8: createOwnerScorer
import org.apache.solr.search.DocSet; //导入依赖的package包/类
public static SolrOwnerScorer createOwnerScorer(Weight weight, AtomicReaderContext context, Bits acceptDocs, SolrIndexSearcher searcher, String authority) throws IOException
{
if (AuthorityType.getAuthorityType(authority) == AuthorityType.USER)
{
DocSet ownedDocs = (DocSet) searcher.cacheLookup(CacheConstants.ALFRESCO_OWNERLOOKUP_CACHE, authority);
if (ownedDocs == null)
{
// Cache miss: query the index for docs where the owner matches the authority.
ownedDocs = searcher.getDocSet(new TermQuery(new Term(QueryConstants.FIELD_OWNER, authority)));
searcher.cacheInsert(CacheConstants.ALFRESCO_OWNERLOOKUP_CACHE, authority, ownedDocs);
}
return new SolrOwnerScorer(weight, ownedDocs, context, acceptDocs, searcher);
}
// Return an empty doc set, as the authority isn't a user.
return new SolrOwnerScorer(weight, new BitDocSet(new FixedBitSet(0)), context, acceptDocs, searcher);
}
示例9: updateDescendantAuxDocs
import org.apache.solr.search.DocSet; //导入依赖的package包/类
private void updateDescendantAuxDocs(NodeMetaData parentNodeMetaData, boolean overwrite,
SolrIndexSearcher solrIndexSearcher, LinkedHashSet<Long> stack, DocSet skippingDocs) throws AuthenticationException,
IOException, JSONException
{
if (stack.contains(parentNodeMetaData.getId()))
{
log.warn("Found aux data loop for node id " + parentNodeMetaData.getId());
log.warn("... stack to node =" + stack);
return;
}
else
{
try
{
stack.add(parentNodeMetaData.getId());
doUpdateDescendantAuxDocs(parentNodeMetaData, overwrite, solrIndexSearcher, stack, skippingDocs);
}
finally
{
stack.remove(parentNodeMetaData.getId());
}
}
}
示例10: getDocSetSize
import org.apache.solr.search.DocSet; //导入依赖的package包/类
@Override
public int getDocSetSize(String targetTxId, String targetTxCommitTime) throws IOException
{
RefCounted<SolrIndexSearcher> refCounted = null;
try
{
refCounted = core.getSearcher(false, true, null);
SolrIndexSearcher solrIndexSearcher = refCounted.get();
BooleanQuery query = new BooleanQuery();
query.add(new TermQuery(new Term(QueryConstants.FIELD_TXID, targetTxId)), Occur.MUST);
query.add(new TermQuery(new Term(QueryConstants.FIELD_TXCOMMITTIME, targetTxCommitTime)), Occur.MUST);
DocSet set = solrIndexSearcher.getDocSet(query);
return set.size();
}
finally
{
if (refCounted != null)
{
refCounted.decref();
}
}
}
示例11: Aggregate
import org.apache.solr.search.DocSet; //导入依赖的package包/类
public Aggregate(SolrQueryRequest req, DocSet base, String fieldName) {
this.base = base;
this.fieldName = fieldName;
this.req = req;
String percentiles = req.getParams().get(GroupByComponent.Params.PERCENTILES, "");
if (percentiles != null && percentiles.isEmpty() == false) {
this.doPercentiles = true;
List<Integer> list = new ArrayList<Integer>();
for (String p : percentiles.split(",")) {
list.add(Integer.parseInt(p));
}
this.requestedPercentiles = list.toArray(new Integer[] {});
this.compression = req.getParams().getDouble(GroupByComponent.Params.PERCENTILES_COMPRESSION, 100);
}
}
示例12: testMultiValued
import org.apache.solr.search.DocSet; //导入依赖的package包/类
@Test
public void testMultiValued() throws Exception {
Query q = parse(COMPONENT_NAME_4);
DocSet docs = searcher.getDocSet(q);
assertEquals(4, docs.size());
DocIterator it = docs.iterator();
assertTrue(it.hasNext());
assertEquals(0, it.nextDoc());
assertTrue(it.hasNext());
assertEquals(1, it.nextDoc());
assertTrue(it.hasNext());
assertEquals(2, it.nextDoc());
assertTrue(it.hasNext());
assertEquals(3, it.nextDoc());
assertFalse(it.hasNext());
}
示例13: findParentIdsForNodes
import org.apache.solr.search.DocSet; //导入依赖的package包/类
private Map<String, Set<String>> findParentIdsForNodes(SolrIndexSearcher searcher, Collection<String> nodeIds) throws IOException {
Map<String, Set<String>> parentIds = new HashMap<>();
LOGGER.debug("Looking up parents for {} nodes", nodeIds.size());
Query filter = buildFilterQuery(getNodeField(), nodeIds);
LOGGER.trace("Filter query: {}", filter);
DocSet docs = searcher.getDocSet(filter);
for (DocIterator it = docs.iterator(); it.hasNext(); ) {
Document doc = searcher.doc(it.nextDoc(), docFields);
String nodeId = doc.get(getNodeField());
Set<String> parentIdValues = new HashSet<>(Arrays.asList(doc.getValues(parentField)));
parentIds.put(nodeId, parentIdValues);
// Record the label, if required
if (isLabelRequired(nodeId)) {
recordLabel(nodeId, doc.getValues(getLabelField()));
}
}
return parentIds;
}
示例14: SimpleFacets
import org.apache.solr.search.DocSet; //导入依赖的package包/类
public SimpleFacets(SolrQueryRequest req,
DocSet docs,
SolrParams params,
ResponseBuilder rb) {
this.req = req;
this.searcher = req.getSearcher();
this.docsOrig = docs;
this.global = params;
this.rb = rb;
}
示例15: getFieldMissingCount
import org.apache.solr.search.DocSet; //导入依赖的package包/类
/**
* Returns a count of the documents in the set which do not have any
* terms for for the specified field.
*
* @see FacetParams#FACET_MISSING
*/
public static int getFieldMissingCount(SolrIndexSearcher searcher, DocSet docs, String fieldName)
throws IOException {
SchemaField sf = searcher.getSchema().getField(fieldName);
DocSet hasVal = searcher.getDocSet
(sf.getType().getRangeQuery(null, sf, null, null, false, false));
return docs.andNotSize(hasVal);
}