You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Adrien Grand (JIRA)" <ji...@apache.org> on 2017/05/24 07:55:04 UTC

[jira] [Commented] (LUCENE-7846) Nested if-then-else in demo/SearchFiles.java

    [ https://issues.apache.org/jira/browse/LUCENE-7846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16022476#comment-16022476 ] 

Adrien Grand commented on LUCENE-7846:
--------------------------------------

This should not be an issue since all documents are created with a path?

> Nested if-then-else in demo/SearchFiles.java
> --------------------------------------------
>
>                 Key: LUCENE-7846
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7846
>             Project: Lucene - Core
>          Issue Type: Improvement
>    Affects Versions: 6.5.1
>            Reporter: www.jbigdata.fr
>            Priority: Minor
>              Labels: easyfix
>
> /demo/src/java/org/apache/lucene/demo/SearchFiles.java
> Line 181-191, nested if avoid the print of title if path is null.
>         Document doc = searcher.doc(hits[i].doc);
>         String path = doc.get("path");
>         if (path != null) {
>           System.out.println((i+1) + ". " + path);
>           String title = doc.get("title");
>           if (title != null) {
>             System.out.println("   Title: " + doc.get("title"));
>           }
>         } else {
>           System.out.println((i+1) + ". " + "No path for this document");
>         }
> --------------------------------------------------------------------------------------
> unnested if-then-else to print the title even if path is null.
>         Document doc = searcher.doc(hits[i].doc);
>         String path = doc.get("path");
>         if (path != null) {
>           System.out.println((i+1) + ". " + path);
>         }
>         else {
>           System.out.println((i+1) + ". " + "No path for this document");
>         }
>         String title = doc.get("title");
>         if (title != null) {
>           System.out.println("   Title: " + title);
>         }
>         else {
>           System.out.println((i+1) + ". " + "No title for this document");
>         }



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org