lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vitaly Stroutchkov <vitaly.stroutch...@kloudville.com>
Subject getting error "<field name> is not a SuggestField"
Date Tue, 01 Aug 2017 23:16:17 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message