28.04.2013 Views

APÉNDICE A : INDEXACIÓN DE INFORMACIÓN . LUCENE 1 ...

APÉNDICE A : INDEXACIÓN DE INFORMACIÓN . LUCENE 1 ...

APÉNDICE A : INDEXACIÓN DE INFORMACIÓN . LUCENE 1 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TOMO I Apéndices técnicos<br />

2.4.2. Búsqueda De Documentos<br />

La búsqueda de documentos constituye la funcionalidad principal<br />

proporcionada por Lucene. Para ello aporta múltiples clases y métodos para la<br />

representación de consultas y para buscar en el índice aquellos documentos que<br />

son relevantes y cumplen con los criterios de la búsqueda. El código que se<br />

muestra a continuación, Search.java, es un sencillo ejemplo de cómo buscar en<br />

un índice.<br />

public class Search {<br />

public static void main(String[] args) throws Exception {<br />

String indexPath = args[0], queryString = args[1];<br />

Searcher searcher = new IndexSearcher(indexPath);<br />

Query query = QueryParser.parse(queryString, "body",<br />

new SimpleAnalyzer());<br />

Hits hits = searcher.search(query);<br />

for (int i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!