changeset 5837:a131314cd734

Ensemble8: IndexSearcher.java code refactoring
author Alexander Kouznetsov
date Wed, 27 Nov 2013 17:38:06 -0800
parents 481c4b8afc28
children 52bc74cf2039
files apps/samples/Ensemble8/src/app/java/ensemble/search/IndexSearcher.java
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/apps/samples/Ensemble8/src/app/java/ensemble/search/IndexSearcher.java	Wed Nov 27 17:33:33 2013 -0800
+++ b/apps/samples/Ensemble8/src/app/java/ensemble/search/IndexSearcher.java	Wed Nov 27 17:38:06 2013 -0800
@@ -109,16 +109,19 @@
                         * just 5 results, but we search for 10 and filter out unsupported
                         * samples and show just 5.
                         */
-                        // If result is a sample, check if supported sample exists before adding so it's
-                        // either not sample or it is a supported sample
-                        if (!result.getDocumentType().name().equals(DocumentType.SAMPLE.name())
-                                || Samples.ROOT.sampleForPath(result.getEnsemblePath().substring(9).trim()) != null) {
-                            results.add(result);
+                        if (docType == DocumentType.SAMPLE) {
+                            if (Samples.ROOT.sampleForPath(result.getEnsemblePath().substring(9).trim()) == null) {
+                                
+                                // Skip unsupported (not existing) samples
+                                continue;
+                            }
                             if (results.size() == 5) {
+                                
                                 // 5 samples is enough
                                 break;
                             }
                         }
+                        results.add(result);
                     } 
                 }
                 resultMap.put(docType, results);