org.apache.lucene.document.FieldSelectorResult Java Examples

The following examples show how to use org.apache.lucene.document.FieldSelectorResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Queries.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public FieldSelectorResult accept(String fieldName) {
    for (Term t : terms) {
        if (fieldName == t.field()) {
            return FieldSelectorResult.LOAD;
        }
    }
    return FieldSelectorResult.NO_LOAD;
}
 
Example #2
Source File: ReferenceCountingReadOnlyIndexReaderFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public FieldSelectorResult accept(String fieldName)
{
    if (fieldName.equals(field))
    {
        return FieldSelectorResult.LOAD;
    }
    else
    {
        return FieldSelectorResult.NO_LOAD;
    }
}
 
Example #3
Source File: AdvancedSearchFieldSelector.java    From drftpd with GNU General Public License v2.0 5 votes vote down vote up
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("type") || fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example #4
Source File: SimpleSearchFieldSelector.java    From drftpd with GNU General Public License v2.0 5 votes vote down vote up
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example #5
Source File: AdvancedSearchFieldSelector.java    From drftpd with GNU General Public License v2.0 5 votes vote down vote up
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("type") || fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example #6
Source File: SimpleSearchFieldSelector.java    From drftpd with GNU General Public License v2.0 5 votes vote down vote up
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example #7
Source File: SearchResultsImpl.java    From olat with Apache License 2.0 5 votes vote down vote up
private List<ResultDocument> initResultList(final Identity identity, final Roles roles, final Query query, final Analyzer analyzer, final Searcher searcher,
        final TopDocs docs, final int firstResult, final int maxReturns, final boolean doHighlight) throws IOException {
    final FieldSelector selector = new FieldSelector() {
        @Override
        public FieldSelectorResult accept(final String fieldName) {
            return (doHighlight || !AbstractOlatDocument.CONTENT_FIELD_NAME.equals(fieldName)) ? FieldSelectorResult.LOAD : FieldSelectorResult.NO_LOAD;
        }
    };

    maxHits = SearchServiceFactory.getService().getSearchModuleConfig().getMaxHits();
    totalHits = docs.totalHits;
    totalDocs = (docs.scoreDocs == null ? 0 : docs.scoreDocs.length);
    final int numOfDocs = Math.min(maxHits, docs.totalHits);
    final List<ResultDocument> res = new ArrayList<ResultDocument>(maxReturns + 1);
    for (int i = firstResult; i < numOfDocs && res.size() < maxReturns; i++) {
        final Document doc = searcher.doc(docs.scoreDocs[i].doc, selector);
        final String reservedTo = doc.get(AbstractOlatDocument.RESERVED_TO);
        if (StringHelper.containsNonWhitespace(reservedTo) && !"public".equals(reservedTo) && !reservedTo.contains(identity.getKey().toString())) {
            continue;// admin cannot see private documents
        }

        final ResultDocument rDoc = createResultDocument(doc, i, query, analyzer, doHighlight, identity, roles);
        if (rDoc != null) {
            res.add(rDoc);
        }

        if (!roles.isOLATAdmin() && i % 10 == 0) {
            // Do commit after certain number of documents because the transaction should not be too big
            DBFactory.getInstance().intermediateCommit();
        }
    }
    return res;
}
 
Example #8
Source File: SearchResultsImpl.java    From olat with Apache License 2.0 5 votes vote down vote up
private List<ResultDocument> initResultList(final Identity identity, final Roles roles, final Query query, final Analyzer analyzer, final Searcher searcher,
        final TopDocs docs, final int firstResult, final int maxReturns, final boolean doHighlight) throws IOException {
    final FieldSelector selector = new FieldSelector() {
        @Override
        public FieldSelectorResult accept(final String fieldName) {
            return (doHighlight || !AbstractOlatDocument.CONTENT_FIELD_NAME.equals(fieldName)) ? FieldSelectorResult.LOAD : FieldSelectorResult.NO_LOAD;
        }
    };

    maxHits = SearchServiceFactory.getService().getSearchModuleConfig().getMaxHits();
    totalHits = docs.totalHits;
    totalDocs = (docs.scoreDocs == null ? 0 : docs.scoreDocs.length);
    final int numOfDocs = Math.min(maxHits, docs.totalHits);
    final List<ResultDocument> res = new ArrayList<ResultDocument>(maxReturns + 1);
    for (int i = firstResult; i < numOfDocs && res.size() < maxReturns; i++) {
        final Document doc = searcher.doc(docs.scoreDocs[i].doc, selector);
        final String reservedTo = doc.get(AbstractOlatDocument.RESERVED_TO);
        if (StringHelper.containsNonWhitespace(reservedTo) && !"public".equals(reservedTo) && !reservedTo.contains(identity.getKey().toString())) {
            continue;// admin cannot see private documents
        }

        final ResultDocument rDoc = createResultDocument(doc, i, query, analyzer, doHighlight, identity, roles);
        if (rDoc != null) {
            res.add(rDoc);
        }

        if (!roles.isOLATAdmin() && i % 10 == 0) {
            // Do commit after certain number of documents because the transaction should not be too big
            DBFactory.getInstance().intermediateCommit();
        }
    }
    return res;
}
 
Example #9
Source File: AllFieldsSelector.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public FieldSelectorResult accept(final String fieldName) {
    return FieldSelectorResult.LOAD;
}