Hi, I created a Lucene index with documents that have a SuggestField. When I run a completion query against it I'm getting an error. The code is like this (not so straightforward in the actual program):
File sdir = new File(sgstPath); Directory sgstDirectory = new MapDirectory(sdir.toPath()); Analyzer sgstAnalyzer = new StandardAnalyzer(); IndexWriterConfig sgstConfig = new IndexWriterConfig(sgstAnalyzer); sgstConfig.setOpenMode(OpenMode.CREATE); IndexWriter sgstWriter = new IndexWriter(sgstDirectory, sgstConfig); ArrayList<Document> docs = new ArrayList<>(); Document doc = new Document(); doc.add(new SuggestField("$suggest", "suggest field content", 1)); docs.add(doc); sgstWriter.addDocuments(docs); sgstWriter.commit(); sgstWriter.close(); DirectoryReader sgstReader = DirectoryReader.open(sgstDirectory); SuggestIndexSearcher sgstSearcher = new SuggestIndexSearcher(sgstReader); CompletionQuery query = new FuzzyCompletionQuery(sgstAnalyzer, new Term("$suggest", "sug")); TopSuggestDocs docs = sgstSearcher.suggest(query, 10, true); On the last row I'm getting exception "$suggest is not a SuggestField". What can be a problem? Thank you, Vitaly