Java Code Examples for org.apache.lucene.document.FieldSelectorResult

The following examples show how to use org.apache.lucene.document.FieldSelectorResult. These examples are extracted from open source projects. 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 Project: netbeans   Source File: Queries.java    License: 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
public FieldSelectorResult accept(String fieldName)
{
    if (fieldName.equals(field))
    {
        return FieldSelectorResult.LOAD;
    }
    else
    {
        return FieldSelectorResult.NO_LOAD;
    }
}
 
Example 3
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("type") || fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example 4
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example 5
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("type") || fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example 6
public FieldSelectorResult accept(String fieldName) {
    if (fieldName.equals("fullPath")) {
        return FieldSelectorResult.LOAD;
    }

    return FieldSelectorResult.LAZY_LOAD;
}
 
Example 7
Source Project: olat   Source File: SearchResultsImpl.java    License: 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 Project: olat   Source File: SearchResultsImpl.java    License: 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 Project: netbeans   Source File: AllFieldsSelector.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FieldSelectorResult accept(final String fieldName) {
    return FieldSelectorResult.LOAD;
}