<!doctype html><htmllang=enclass="js csstransforms3d"><head><metacharset=utf-8><metaname=viewportcontent="width=device-width,initial-scale=1"><metaname=generatorcontent="Hugo 0.80.0"><metaname=descriptioncontent="Strolch is a parameterized framework for use on servers and IoT"><metaname=authorcontent="Strolch"><linkrel=iconhref=/favicon.icotype=image/ico><title>Searches - Strolch</title><linkhref=/css/nucleus.css?1626430354rel=stylesheet><linkhref=/css/fontawesome-all.min.css?1626430354rel=stylesheet><linkhref=/css/hybrid.css?1626430354rel=stylesheet><linkhref=/css/featherlight.min.css?1626430354rel=stylesheet><linkhref=/css/perfect-scrollbar.min.css?1626430354rel=stylesheet><linkhref=/css/auto-complete.css?1626430354rel=stylesheet><linkhref=/css/atom-one-dark-reasonable.css?1626430354rel=stylesheet><linkhref=/css/theme.css?1626430354rel=stylesheet><linkhref=/css/hugo-theme.css?1626430354rel=stylesheet><linkhref=/css/theme-green.css?1626430354rel=stylesheet><scriptsrc=/js/jquery-3.3.1.min.js?1626430354></script><style>:root#header+#content>#left>#rlblock_left{display:none!important}</style></head><bodydata-url=/documentation/searches/><navid=sidebar><divid=header-wrapper><divid=header><aid=logohref=/><imgsrc=/logo.png></a></div><divclass=searchbox><labelfor=search-by><iclass="fas fa-search"></i></label><inputdata-search-inputid=search-bytype=searchplaceholder=Search...>
parent"><ahref=/documentation/>Documentation</a><ul><lidata-nav-id=/documentation/architecture/title=Architectureclass=dd-item><ahref=/documentation/architecture/>Architecture</a></li><lidata-nav-id=/documentation/model/title=Modelclass=dd-item><ahref=/documentation/model/>Model</a></li><lidata-nav-id=/documentation/do-and-donts/title="Do and Don't"class=dd-item><ahref=/documentation/do-and-donts/>Do and Don't</a></li><lidata-nav-id=/documentation/runtime-configuration/title="Runtime Configuration"class=dd-item><ahref=/documentation/runtime-configuration/>Runtime Configuration</a></li><lidata-nav-id=/documentation/realms/title=Realmsclass=dd-item><ahref=/documentation/realms/>Realms</a></li><lidata-nav-id=/documentation/components/title=Componentsclass=dd-item><ahref=/documentation/components/>Components</a></li><lidata-nav-id=/documentation/services-and-commands/title="Services and Commands"class=dd-item><ahref=/documentation/services-and-commands/>Services and Commands</a></li><lidata-nav-id=/documentation/searches/title=Searchesclass="dd-item active"><ahref=/documentation/searches/>Searches</a></li><lidata-nav-id=/documentation/queries/title=Queriesclass=dd-item><ahref=/documentation/queries/>Queries</a></li><lidata-nav-id=/documentation/transactions/title=Transactionsclass=dd-item><ahref=/documentation/transactions/>Transactions</a></li><lidata-nav-id=/documentation/policies/title=Policiesclass=dd-item><ahref=/documentation/policies/>Policies</a></li><lidata-nav-id=/documentation/observers/title=Observersclass=dd-item><ahref=/documentation/observers/>Observers</a></li><lidata-nav-id=/documentation/versioning/title=Versioningclass=dd-item><ahref=/documentation/versioning/>Versioning</a></li><lidata-nav-id=/documentation/reports/title=Reportsclass=dd-item><ahref=/documentation/reports/>Reports</a></li><lidata-nav-id=/documentation/priviles/title=Privilegesclass=dd-item><ahref=/documentation/priviles/>Privileges</a></li></ul></li><lidata-nav-id=/plc/title=PLCclass=dd-item><ahref=/plc/>PLC</a><ul><lidata-nav-id=/plc/architecture/title=Architectureclass=dd-item><ahref=/plc/architecture/>Architecture</a></li><lidata-nav-id=/plc/example-set-up/title="Example Set-Up"class=dd-item><ahref=/plc/example-set-up/>Example Set-Up</a></li></ul></li><lidata-nav-id=/tutorial/title=Tutorialclass=dd-item><ahref=/tutorial/>Tutorial</a><ul><lidata-nav-id=/tutorial/configuration/title=Configurationclass=dd-item><ahref=/tutorial/configuration/>Configuration</a></li><lidata-nav-id=/tutorial/model/title=Modelclass=dd-item><ahref=/tutorial/model/>Model</a></li><lidata-nav-id=/tutorial/crud-book/title="CRUD Book"class=dd-item><ahref=/tutorial/crud-book/>CRUD Book</a></li></ul></li><lidata-nav-id=/download/title=Downloadclass=dd-item><ahref=/download/>Download</a></li><lidata-nav-id=/development/title=Developmentclass=dd-item><ahref=/development/>Development</a></li><lidata-nav-id=/blog/title=Blogclass=dd-item><ahref=/blog/>Blog</a><ul><lidata-nav-id=/blog/post-00015/title="Release of Strolch 1.6.100"class=dd-item><ahref=/blog/post-00015/>Release of Strolch 1.6.100</a></li><lidata-nav-id=/blog/post-00014/title="Strolch Reports"class=dd-item><ahref=/blog/post-00014/>Strolch Reports</a></li><lidata-nav-id=/blog/post-00013/title="Strolch Searches"class=dd-item><ahref=/blog/post-00013/>Strolch Searches</a></li><lidata-nav-id=/blog/post-00012/title="Wow, the many changes!"class=dd-item><ahref=/blog/post-00012/>Wow, the many changes!</a></li><lidata-nav-id=/blog/post-00011/title="Strolch now on Maven Central"class=dd-item><ahref=/blog/post-00011/>Strolch now on Maven Central</a></li><lidata-nav-id=/blog/post-00010/title="Versioning of objects"class=dd-item><ahref=/blog/post-00010/>Versioning of objects</a></li><lidata-nav-id=/blog/post-00009/title="Release 1.2.0"class=dd-item><ahref=/blog/post-00009/>Release 1.2.0</a></li><lidata-nav-id=/blog/post-00008/title="Strolch Update"class=dd-item><ahref=/blog/post-00008/>Strolch
from the <ahref=https://camel.apache.org/target=_blank>Apache Camel</a> project.</p><p>There are four main search classes:</p><ul><li>RootElementSearch - search for any of Resource, Order or Activity elements</li><li>ResourceSearch - search for Resources</li><li>OrderSearch - search for Orders</li><li>ActivitySearch - search for Activities</li></ul><p>No search is useful without a <code>where</code> clause, which are called search
expressions. When writing a search, there are multiple ways to add such where
clauses. Either</p><ul><li>override the <code>define()</code>-method in your sub class and add the where clauses by
calling the <code>where()</code> method, or</li><li>define special methods on the class e.g. <code>byColor()</code> which also calls the
<code>where()</code>-method to add a search expression, or</li><li>directly call the <code>where()</code>-method after instantiating a search.</li></ul><p>When extending the class, then the search expressions are available as methods
on the super class, otherwise you can statically import them from
.</p><p>Examples of search expressions with search predicates follow:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javadata-lang=java>ResourceSearch search<spanstyle=color:#f92672>=</span><spanstyle=color:#66d9ef>new</span> ResourceSearch<spanstyle=color:#f92672>();</span>
<spanstyle=color:#75715e>// predicate either as parameter, or chained
</code></pre></div><p>Note how the predicates can be chained to the search expression, or passed as a
parameter to the expression.</p><p>In addition to using predefined search search expressions, one can also just
pass a lambda expression which performs a custom filter:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javadata-lang=java>personSearch<spanstyle=color:#f92672>.</span><spanstyle=color:#a6e22e>where</span><spanstyle=color:#f92672>(</span>person <spanstyle=color:#f92672>-></span> person<spanstyle=color:#f92672>.</span><spanstyle=color:#a6e22e>getName</span><spanstyle=color:#f92672>().</span><spanstyle=color:#a6e22e>length</span><spanstyle=color:#f92672>()</span><spanstyle=color:#f92672>==</span> 3<spanstyle=color:#f92672>);</span>
the <ahref=https://github.com/strolch-li/strolch/blob/develop/li.strolch.agent/src/test/java/li/strolch/search/StrolchSearchTest.javatarget=_blank>StrolchSearchTest</a>
for many ways in which you can implement tests.</p><divclass="notices tip"><p>Note that strolch searches requires privileges, thus when you
use a strolch search, add it to the role of the user in <code>PrivilegeRoles.xml</code>:</p></div><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-xmldata-lang=xml>
<spanstyle=color:#f92672></Allow></span><spanstyle=color:#75715e><!-- internal used for when the search is done in an internal service --></span>