From 021e328676b4cc8c3099b2f89b291fc15c25ba46 Mon Sep 17 00:00:00 2001 From: Otis Gospodnetic Date: Tue, 1 Jan 2002 00:26:14 +0000 Subject: [PATCH] - Applied a patch submitted by Paul Spencer. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149638 13f79535-47bb-0310-9956-ffa450edef68 --- src/demo/org/apache/lucene/SearchFiles.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/demo/org/apache/lucene/SearchFiles.java b/src/demo/org/apache/lucene/SearchFiles.java index c83c333c480..148af811391 100644 --- a/src/demo/org/apache/lucene/SearchFiles.java +++ b/src/demo/org/apache/lucene/SearchFiles.java @@ -90,8 +90,22 @@ class SearchFiles { final int HITS_PER_PAGE = 10; for (int start = 0; start < hits.length(); start += HITS_PER_PAGE) { int end = Math.min(hits.length(), start + HITS_PER_PAGE); - for (int i = start; i < end; i++) - System.out.println(i + ". " + hits.doc(i).get("path")); + for (int i = start; i < end; i++) { + Document doc = hits.doc(i); + String path = doc.get("path"); + if (path != null) { + System.out.println(i + ". " + path); + } else { + String url = doc.get("url"); + if (url != null) { + System.out.println(i + ". " + url); + System.out.println(" - " + doc.get("title")); + } else { + System.out.println(i + ". " + "No path nor URL for this document"); + } + } + } + if (hits.length() > end) { System.out.print("more (y/n) ? "); line = in.readLine();