Questão #11143632016

Programação (TI)

public static void main(String[] args) throws CorruptIndexException,

LockObtainFailedException, IOException, ParseException {

Path path = Paths.get(lucene_tribunal);

Directory fsDir = FSDirectory.open(path);

Analyzer an = new StandardAnalyzer();

IndexWriterConfig iwc = new

IndexWriterConfig(an);

try (IndexWriter indexWriter = new IndexWriter(fsDir, iwc)) {

Document doc = new Document();

doc.add(new StringField(titulo, Algoritmos, Store.YES));

doc.add(new StringField(chave, algoritmo, Store.NO));

doc.add(new StringField(chave, estrutura dados, Store.YES));

doc.add(new StringField(chave, grafos, Store.YES));

doc.add(new StringField(chave, graficos, Store.YES));

doc.add(new StringField(isbn, 9788535236996, Store.NO));

indexWriter.addDocument(doc);

int numDocs = indexWriter.numDocs();

System.out.println(num docs= + numDocs);

}

IndexReader dir =

DirectoryReader.open(FSDirectory.open(path));

IndexSearcher is = new IndexSearcher(dir);

Analyzer analyzer = new StandardAnalyzer();

QueryParser parser = new QueryParser(chave, analyzer);

Query query;

query = parser.parse(gr*);

TopDocs hits = is.search(query,10);

System.out.println(Total Hits=+hits.totalHits);

dir.close();

}

Assinale a opção que apresenta o resultado do código Java precedente, que utiliza a biblioteca Lucene.