List of usage examples for org.apache.lucene.search.suggest.analyzing AnalyzingInfixSuggester AnalyzingInfixSuggester
public AnalyzingInfixSuggester(Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, boolean commitOnBuild) throws IOException
From source file:com.shaie.suggest.ContextSuggestDemo.java
License:Apache License
public ContextSuggestDemo() throws IOException { indexDir = new RAMDirectory(); suggestDir = new RAMDirectory(); analyzer = new SimpleAnalyzer(); suggester = new AnalyzingInfixSuggester(suggestDir, analyzer, analyzer, 1, true); buildSearchIndex();//from w w w . j a va 2s.c o m buildSuggesterIndex(); }
From source file:net.tourbook.search.FTSearchManager.java
License:Open Source License
private static Lookup setupSuggester_AnalyzingInfix() { setupIndexReader();/*from w w w . j a v a 2 s . c o m*/ final Lookup suggester[] = new AnalyzingInfixSuggester[1]; Display.getDefault().syncExec(new Runnable() { @Override public void run() { BusyIndicator.showWhile(Display.getDefault(), new Runnable() { @Override public void run() { try { final DocumentInputIterator inputIterator = new DocumentInputIterator(_indexReader); final Analyzer indexAnalyzer = new StandardAnalyzer(new CharArraySet(0, true)); final Analyzer queryAnalyzer = new WhitespaceAnalyzer(); _infixStore = openStore("AnalyzingInfixSuggesterSTORE"); //$NON-NLS-1$ suggester[0] = new AnalyzingInfixSuggester(LUCENE_VERSION, _infixStore, indexAnalyzer, queryAnalyzer, 2); suggester[0].build(inputIterator); } catch (final Exception e) { StatusUtil.showStatus(e); } } }); } }); return suggester[0]; }
From source file:org.apache.jackrabbit.oak.plugins.index.lucene.util.SuggestHelper.java
License:Apache License
public static AnalyzingInfixSuggester getLookup(final Directory suggestDirectory, Analyzer analyzer, final File tempDir) throws IOException { return new AnalyzingInfixSuggester(Version.LUCENE_47, tempDir, analyzer, analyzer, 3) { @Override//from w w w . j a va2 s. com protected Directory getDirectory(File path) throws IOException { if (tempDir == null || tempDir.getAbsolutePath().equals(path.getAbsolutePath())) { return suggestDirectory; // use oak directory for writing suggest index } else { return FSDirectory.open(path); // use FS for temp index used at build time } } }; }
From source file:org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory.java
License:Apache License
@Override public Lookup create(NamedList params, SolrCore core) { // mandatory parameter Object fieldTypeName = params.get(QUERY_ANALYZER); if (fieldTypeName == null) { throw new IllegalArgumentException( "Error in configuration: " + QUERY_ANALYZER + " parameter is mandatory"); }//from w w w . ja v a2 s . com FieldType ft = core.getLatestSchema().getFieldTypeByName(fieldTypeName.toString()); Analyzer indexAnalyzer = ft.getAnalyzer(); Analyzer queryAnalyzer = ft.getQueryAnalyzer(); // optional parameters String indexPath = params.get(INDEX_PATH) != null ? params.get(INDEX_PATH).toString() : DEFAULT_INDEX_PATH; int minPrefixChars = params.get(MIN_PREFIX_CHARS) != null ? Integer.parseInt(params.get(MIN_PREFIX_CHARS).toString()) : AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS; try { return new AnalyzingInfixSuggester(core.getSolrConfig().luceneMatchVersion, new File(indexPath), indexAnalyzer, queryAnalyzer, minPrefixChars); } catch (IOException e) { throw new RuntimeException(); } }