Java Code Examples for org.apache.lucene.util.Version#LUCENE_31
The following examples show how to use
org.apache.lucene.util.Version#LUCENE_31 .
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: BaseDao.java From projectforge-webapp with GNU General Public License v3.0 | 7 votes |
private org.apache.lucene.search.Query createFullTextQuery(final String[] searchFields, final QueryFilter queryFilter, final String searchString) { final MultiFieldQueryParser parser = new MultiFieldQueryParser(LUCENE_VERSION, searchFields, new ClassicAnalyzer(Version.LUCENE_31)); parser.setAllowLeadingWildcard(true); org.apache.lucene.search.Query query = null; try { query = parser.parse(searchString); } catch (final org.apache.lucene.queryParser.ParseException ex) { final String errorMsg = "Lucene error message: " + ex.getMessage() + " (for " + this.getClass().getSimpleName() + ": " + searchString + ")."; if (queryFilter != null) { queryFilter.setErrorMessage(errorMsg); } log.info(errorMsg); return null; } return query; }
Example 2
Source File: IndexSearcher.java From marathonv5 with Apache License 2.0 | 5 votes |
public IndexSearcher() { try { searcher = new org.apache.lucene.search.IndexSearcher(new ClasspathDirectory()); } catch (IOException e) { e.printStackTrace(); } analyzer = new StandardAnalyzer(Version.LUCENE_31); parser = new MultiFieldQueryParser(Version.LUCENE_31, new String[]{"name","description"}, analyzer); }
Example 3
Source File: IndexSearcher.java From marathonv5 with Apache License 2.0 | 5 votes |
public IndexSearcher() { try { searcher = new org.apache.lucene.search.IndexSearcher(new ClasspathDirectory()); } catch (IOException e) { e.printStackTrace(); } analyzer = new StandardAnalyzer(Version.LUCENE_31); parser = new MultiFieldQueryParser(Version.LUCENE_31, new String[]{"name","description"}, analyzer); }
Example 4
Source File: LuceneMessageSearchIndex.java From james-project with Apache License 2.0 | 5 votes |
protected IndexWriterConfig createConfig(Analyzer analyzer, boolean dropIndexOnStart) { IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_31, analyzer); if (dropIndexOnStart) { config.setOpenMode(OpenMode.CREATE); } else { config.setOpenMode(OpenMode.CREATE_OR_APPEND); } return config; }
Example 5
Source File: BuildEnsembleSearchIndex.java From marathonv5 with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception{ File samplesFilesDir = new File("build/classes/ensemble/"); File indexDir = new File("build/classes/ensemble/search/index"); File docDir = new File("../../../artifacts/sdk/docs/api"); File samplesDir = new File("src/ensemble/samples"); // create index ///System.out.println("Indexing to directory '" + indexDir + "'..."); long start = System.currentTimeMillis(); Directory dir = FSDirectory.open(indexDir); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31); IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); iwc.setOpenMode(OpenMode.CREATE); // generate and write index of all java doc and samples IndexWriter writer = new IndexWriter(dir, iwc); List<String> samplesFileList = new ArrayList<String>(); indexSamples(writer, samplesDir, samplesFileList); try { indexJavaDocAllClasses(writer, docDir); } catch (Exception e) { System.out.println("\nWarning: We were not able to locate the JavaFX API documentation for your build environment.\n" + "Ensemble search will not include the API documentation.\n"); } writer.close(); // create a listAll.txt file that is used FileWriter listAllOut = new FileWriter(new File(indexDir,"listAll.txt")); for (String fileName: dir.listAll()) { if (!"listAll.txt".equals(fileName)) { // don't include the "listAll.txt" file Long length = dir.fileLength(fileName); listAllOut.write(fileName); listAllOut.write(':'); listAllOut.write(length.toString()); listAllOut.write('\n'); } } listAllOut.flush(); listAllOut.close(); FileWriter sampleFilesCache = new FileWriter(new File(samplesFilesDir,"samplesAll.txt")); for (String oneSample: samplesFileList) { sampleFilesCache.write(oneSample); sampleFilesCache.write('\n'); } sampleFilesCache.flush(); sampleFilesCache.close(); // print time taken ///System.out.println(System.currentTimeMillis() - start + " total milliseconds"); }
Example 6
Source File: BuildEnsembleSearchIndex.java From marathonv5 with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception{ File samplesFilesDir = new File("build/classes/ensemble/"); File indexDir = new File("build/classes/ensemble/search/index"); File docDir = new File("../../../artifacts/sdk/docs/api"); File samplesDir = new File("src/ensemble/samples"); // create index ///System.out.println("Indexing to directory '" + indexDir + "'..."); long start = System.currentTimeMillis(); Directory dir = FSDirectory.open(indexDir); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31); IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); iwc.setOpenMode(OpenMode.CREATE); // generate and write index of all java doc and samples IndexWriter writer = new IndexWriter(dir, iwc); List<String> samplesFileList = new ArrayList<String>(); indexSamples(writer, samplesDir, samplesFileList); try { indexJavaDocAllClasses(writer, docDir); } catch (Exception e) { System.out.println("\nWarning: We were not able to locate the JavaFX API documentation for your build environment.\n" + "Ensemble search will not include the API documentation.\n"); } writer.close(); // create a listAll.txt file that is used FileWriter listAllOut = new FileWriter(new File(indexDir,"listAll.txt")); for (String fileName: dir.listAll()) { if (!"listAll.txt".equals(fileName)) { // don't include the "listAll.txt" file Long length = dir.fileLength(fileName); listAllOut.write(fileName); listAllOut.write(':'); listAllOut.write(length.toString()); listAllOut.write('\n'); } } listAllOut.flush(); listAllOut.close(); FileWriter sampleFilesCache = new FileWriter(new File(samplesFilesDir,"samplesAll.txt")); for (String oneSample: samplesFileList) { sampleFilesCache.write(oneSample); sampleFilesCache.write('\n'); } sampleFilesCache.flush(); sampleFilesCache.close(); // print time taken ///System.out.println(System.currentTimeMillis() - start + " total milliseconds"); }
Example 7
Source File: LenientImapSearchAnalyzer.java From james-project with Apache License 2.0 | 4 votes |
@Override public TokenStream tokenStream(String arg0, Reader reader) { return new ShingleFilter(new UpperCaseFilter(new WhitespaceTokenizer(Version.LUCENE_31, reader)), 2, maxTokenLength); }