- }
- } else {
- Resource project = Simantics.peekProjectResource();
- if (project != null) {
- IResourceFilter rf = resourceFilter;
- String filter = getFilterForResourceFilter(rf);
- if (!filter.isEmpty())
- filter += " AND ";
- filter += "Name:" + pattern + "*";
-
- Layer0 L0 = Layer0.getInstance(graph);
-
- Set<Resource> indexRoots = new HashSet<>();
- indexRoots.addAll(graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, L0.IndexRoot)));
- indexRoots.addAll(graph.syncRequest(new OntologiesFromLibrary(graph.getRootLibrary())));
- for (Resource indexRoot : indexRoots) {
- Collection<Resource> hits = find(graph, indexRoot, filter);
- for (Resource r : hits) {
- if (rf != null && !rf.acceptResource(graph, r))
- continue;
- contentProvider.add(new LabeledResource(DebugUtils.getSafeLabel(graph, r), r), itemsFilter);
+ } else {
+ String[] terms = pattern.trim().split("\\s+"); //$NON-NLS-1$
+ if (terms.length == 0) return;
+
+ Resource project = Simantics.peekProjectResource();
+ if (project != null) {
+ Layer0 L0 = Layer0.getInstance(graph);
+ IResourceFilter rf = resourceFilter;
+ String filter = getFilterForResourceFilter(L0, rf);
+ if (!filter.isEmpty())
+ filter += " AND "; //$NON-NLS-1$
+
+ filter += Dependencies.FIELD_NAME_SEARCH + ":("; //$NON-NLS-1$
+ filter += Arrays.stream(terms).map(term -> "+" + IndexQueries.escape(term.toLowerCase(), false) + "*").collect(Collectors.joining(" ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ filter +=")"; //$NON-NLS-1$
+
+ Set<Resource> indexRoots = new HashSet<>();
+ indexRoots.addAll(graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, L0.IndexRoot)));
+ indexRoots.addAll(graph.syncRequest(new OntologiesFromLibrary(graph.getRootLibrary())));
+ for (Resource indexRoot : indexRoots) {
+ Collection<Resource> hits = find(graph, indexRoot, filter);
+ for (Resource r : hits) {
+ if (rf != null && !rf.acceptResource(graph, r))
+ continue;
+ searchResults.add(new LabeledResource(DebugUtils.getSafeLabel(graph, r), r));
+ }