lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "www.jbigdata.fr (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LUCENE-7846) Nested if-then-else in demo/SearchFiles.java
Date Tue, 23 May 2017 08:24:04 GMT

     [ https://issues.apache.org/jira/browse/LUCENE-7846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

www.jbigdata.fr updated LUCENE-7846:
------------------------------------
    Summary: Nested if-then-else in demo/SearchFiles.java  (was: Nested if-then-else)

> 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


Mime
View raw message