JBoss Community Archive (Read Only)

RHQ 4.9

Search

Advanced Topics

Complex Search Expressions

  • searchTermA searchTermB

    • find results that match both search terms

  • searchTermA | searchTermB

    • find results that match either search term

  • searchTermA | searchTermB searchTermC

    • find results that match search terms B and C, or which matches search term A. in other words, 'and' has a higher precendence than 'or'

  • searchTermA (searchTermB | searchTermC)

    • find results that match search term A as well as one (or both) of search terms B and C. here, we use parentheses to override the default precedence, which forces the 'or'ed terms to be evaluated first, then 'and' the result of that together with search term A

Result Matching using Quotes

A search term can basically take one of three forms:

<value>
<context> <comparisonOperator> <value>
<context> [ <parameter> ] <comparisonOperator> <value>

Quote-handling mainly concerns how single-quotes and double-quotes are handled for <value> suggestions.

Note: in a future release, we will likely extend the sophisticated quote support to <parameter> name suggestions as well

As long as you don't have any white-space in the term you're searching for, you don't need quotes at all.

1a) portal-war
2a) plugin=jboss
3a) trait[partitionName]=mycoolcluster

If you add more search terms after these:

1b) portal-war rhq
2b) plugin=jboss rhq
3b) trait[partitionName]=mycoolcluster rhq

The whitespace is treated as a term separator. Thus, 2b means "search for resources whose name contains 'rhq' and whose type was defined by a plugin with 'jboss' in the name" and 3b means "search for resources whose name contains 'rhq' and whose partitionName trait contains 'mycoolcluster'".

If, however, the user wants to interpret white-space characters literally, then single-quotes or double-quotes must be used. The following search expressions are all equivalent.

"Agent Plugin Container"
'Agent Plugin Container'
name="Agent Plugin Container"
name='Agent Plugin Container'

Thus, there is no semantic difference between single-quotes and double-quotes; they exist purely to treat the white-space in between them as literal value characters.

But what happens if you have a resource whose name is:

joseph's cool resource

In this case, the resource name already has a single-quote in it, as well as white-space. So, the only way to find this resource unambiguously is to use the opposite style quotes for the boundary characters:

"joseph's cool resource"
name="joseph's cool resource"

Or even matching on part of the name, but still using opposite style quotes:

"joseph's"
name="joseph's"

Likewise, if your resource has double-quotes in the name:

silly " resource

Then you would use single-quotes to find it:

'silly " resource'
name='silly " resource'

Keep in mind that quotes are NOT necessary as boundary character unless you have white-space in the name. So, excluding boundary quotes, I could search for:

joseph's

And it will work just the same. In other words, single-quotes and double-quotes can freely occur anywhere inside the item being searched for; they only get special treatment when they are the boundary characters.

However, excluding boundary quotes, if I searched for:

joseph's cool resource

This search expression would actually be interpreted as searching for resources whose name contains all of the following 3 terms: joseph's, cool, and resource (because the white-space will be interpreted as term separators). Granted, it will still find the resource that you're looking for, but it may return other resources as well. So by adding quotes:

"joseph's cool resource"

You are ensuring that you search for resources whose names have those three terms exactly in the order presented and with precisely the amount of white-space you entered between the quotes.

Improper Usage of Quotes

If you start a search term with single-quotes or double-quotes, then the search system expects your term to end in the same type of quotes that it began. Thus, the following expressions are all invalid:

  • "hello'

    • must end with same quote as it began

  • 'world"

    • must end with same quote as it began

  • "foo

    • must end with double-quote

  • 'bar

    • must end with single-quote

  • "cat"in

    • the last two characters are interpreted as junk, and should either be removed or white-space added to separate the quoted term (cat) from the unquoted one (in)

  • "the"hat"

    • need to use alternating style quotes, if you wanted to search for terms containing double-quotes, simply enclose the term with single-quotes as follows 'the"hat' (recall, however, that boundary quotes are only necessary if the thing you're attempting to filter by contains white-space)

Search Suggestions using Quotes

The search suggestions are intelligent insofar as they will recognize whether you've started a search term with a quote, and then provide suggestions which respect that quote-style. For example, if a search term began with a double-quote character, here are what the suggestions would look like:

images/author/download/attachments/73140003/simple_text_suggestions_4.png

Notice how only some of the suggestions get quoted. This indicates that quotes were unnecessary for those results because they do not contain any white-space that needed to be escaped. However, if there are any suggestions that contained white-space, then those items will be wrapped with the quote-style that you began the current search term with, in this case double-quotes.

Here is an example of what it would look like if the search began with a single-quote:

images/author/download/attachments/73140003/simple_text_suggestions_5.png

Again, only some of the results are quoted – only ones that need to be quoted to escape the white-space in their values.

In general, though, you really don't have to worry about which, if any, style quotes you start your search term with. The search system is intelligent enough to wrap your suggestions in the appropriate quotes, and only as necessary. For example:

images/author/download/attachments/73140003/simple_text_suggestions_6.png

Here you see that the first suggestion contained data with double-quotes in it, so it was wrapped in single-quotes. The second suggestion was the opposite case, where the data contained single-quotes so it had to be wrapped in double-quotes. The last suggestion, because it did not contain any white-space, did not need to be wrapped in quotes at all.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 08:46:54 UTC, last content change 2013-09-18 19:43:48 UTC.