Example usage for org.apache.lucene.analysis.standard StandardAnalyzer setMaxTokenLength

List of usage examples for org.apache.lucene.analysis.standard StandardAnalyzer setMaxTokenLength

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.standard StandardAnalyzer setMaxTokenLength.

Prototype

public void setMaxTokenLength(int length) 

Source Link

Document

Set the max allowed token length.

Usage

From source file:org.cytoscape.search.internal.EnhancedSearchIndex.java

License:Open Source License

private void BuildIndex(RAMDirectory idx, CyNetwork network) {

    try {//from   www . j  a  va  2 s  . c  o m
        // Make a writer to create the index, empty set of stop words (redmine #3808)
        StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_30, Collections.emptySet());
        analyzer.setMaxTokenLength(1024 * 10);
        IndexWriter writer = new IndexWriter(idx, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);

        // Add a document for each graph object - node and edge
        List<CyNode> nodeList = network.getNodeList();

        this.taskMonitor.setProgress(0.1);
        for (CyNode cyNode : nodeList) {
            writer.addDocument(createDocument(network, cyNode, EnhancedSearch.NODE_TYPE, cyNode.getSUID()));

        }
        this.taskMonitor.setProgress(0.6);

        List<CyEdge> edgeList = network.getEdgeList();
        for (CyEdge cyEdge : edgeList) {
            writer.addDocument(createDocument(network, cyEdge, EnhancedSearch.EDGE_TYPE, cyEdge.getSUID()));
        }

        // Optimize and close the writer to finish building the index
        writer.optimize();
        writer.close();

    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    this.taskMonitor.setProgress(0.95);

}

From source file:org.cytoscape.search.internal.util.CustomMultiFieldQueryParser.java

License:Open Source License

public CustomMultiFieldQueryParser(AttributeFields attrFields, StandardAnalyzer analyzer) {
    super(Version.LUCENE_30, attrFields.getFields(), analyzer);
    analyzer.setMaxTokenLength(1024 * 10); // Increase for sequences
    this.attrFields = attrFields;
    setAllowLeadingWildcard(true);/*from  w ww  . j  a  va2s.c  o m*/
}