www.jbigdata.fr created LUCENE-7846:
---------------------------------------

             Summary: Nested if-then-else
                 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


/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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to