<%-- CDDL HEADER START The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. See LICENSE.txt included in this distribution for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at LICENSE.txt. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] CDDL HEADER END Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. Portions Copyright 2011 Jens Elkner. Portions Copyright (c) 2018, 2020, Chris Fraire . Portions Copyright (c) 2022, Krystof Tulinger . --%> <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page session="false" errorPage="error.jsp" import=" org.opengrok.indexer.search.SearchEngine, org.opengrok.web.PageConfig, org.opengrok.indexer.web.QueryParameters" %> <% /* ---------------------- help.jsp start --------------------- */ { PageConfig cfg = PageConfig.get(request); cfg.checkSourceRootExistence(); cfg.setTitle("OpenGrok Help"); } %><%@ include file="httpheader.jspf" %>
<%@include file="pageheader.jspf" %>
Help page

Examples:


To find where setResourceMonitors is defined:

    <%= QueryBuilder.DEFS %>:setResourceMonitors

To find files that use sprintf in usr/src/cmd/cmd-inet/usr.sbin/:
<%= QueryBuilder.REFS %>:sprintf <%= QueryBuilder.PATH %>:usr/src/cmd/cmd-inet/usr.sbin

To find assignments to variable foo:
"foo ="

    To find Makefiles where the pstack binary is being built:
pstack <%= QueryBuilder.PATH %>:Makefile

to search for phrase "Bill Joy":
"Bill Joy"

To find perl files that do not use /usr/bin/perl but something else:
-"/usr/bin/perl" +"/bin/perl"

To find all strings beginning with foo use the wildcard:
foo*

To find all files which have . c in their name (dot is a token!):
". c"

To find all files which start with "ma" and then have only alphabet characters do:

    <%= QueryBuilder.PATH %>:/ma[a-zA-Z]*/

To find all main methods in all files analyzed by C analyzer (so .c, .h, ...) do:
main <%= QueryBuilder.TYPE %>:c

More info:

A Query is a series of clauses. A clause may be prefixed by:
  • a plus "+" or a minus "-" sign, indicating that the clause is required or prohibited respectively; or
  • a term followed by a colon ":", indicating the field to be searched. This enables one to construct queries which search multiple fields.

A clause may be either:

  • a term, indicating all the documents that contain this term; or
  • a phrase - group of words surrounded by double quotes " ", e.g. "hello dolly"
  • a nested query, enclosed in parentheses "(" ")" (also called query/field grouping) . Note that this may be used with a +/- prefix to require any of a set of terms.
  • boolean operators which allow terms to be combined through logic operators. Supported are AND(&&), "+", OR(||), NOT(!) and "-" (Note: they must be ALL CAPS).

Regular Expression, Wildcard, Fuzzy, Proximity and Range Searches:

  • to perform a regular expression search use the "/" enclosure, e.g. /[mb]an/ - will search for man or for ban;
    NOTE: path field search escapes "/" by default, so it only supports regexps when the search string starts and ends with "/".
    More info can be found on Lucene regexp page.
  • to perform a single character wildcard search use the "?" symbol, e.g. te?t
  • to perform a multiple character wildcard search use the "*" symbol, e.g. test* or te*t
  • you can use a * or ? symbol as the first character of a search (unless not enabled using indexer option -a).
  • to do a fuzzy search (find words similar in spelling, based on the Levenshtein Distance, or Edit Distance algorithm) use the tilde, "~", e.g. rcs~
  • to do a proximity search use the tilde, "~", symbol at the end of a Phrase. For example to search for a "opengrok" and "help" within 10 words of each other enter: "opengrok help"~10
  • range queries allow one to match documents whose field(s) values are between the lower and upper bound specified by the Range Query. Range Queries can be inclusive or exclusive of the upper and lower bounds. Sorting is done lexicographically. Inclusive queries are denoted by square brackets [ ] , exclusive by curly brackets { }. For example: title:{Aida TO Carmen} - will find all documents between Aida to Carmen, exclusive of Aida and Carmen.
Escaping special characters:

Opengrok supports escaping special characters that are part of the query syntax. Current special characters are:
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
To escape these character use the \ before the character. For example to search for (1+1):2 use the query: \(1\+1\)\:2

NOTE on analyzers: Indexed words are made up of Alpha-Numeric and Underscore characters. One letter words are usually not indexed as symbols!
Most other characters (including single and double quotes) are treated as "spaces/whitespace" (so even if you escape them, they will not be found, since most analyzers ignore them).
The exceptions are: @ $ % ^ & = ? . : which are mostly indexed as separate words.
Because some of them are part of the query syntax, they must be escaped with a reverse slash as noted above.
So searching for \+1 or \+ 1 will both find +1 and + 1.

Valid FIELDs are

full
Search through all text tokens (words,strings,identifiers,numbers) in index.
defs
Only finds symbol definitions (where e.g. a variable (function, ...) is defined).
refs
Only finds symbols (e.g. methods, classes, functions, variables).
path
path of the source file (no need to use dividers, or if, then use "/" - Windows users, "\" is an escape key in Lucene query syntax!
Please don't use "\", or replace it with "/").
Also note that if you want just exact path, enclose it in "", e.g. "src/mypath", otherwise dividers will be removed and you get more hits.
<% if (PageConfig.get(request).getEnv().isHistoryEnabled()) { %>
hist
History log comments.
<% } %>
type
Type of analyzer used to scope down to certain file types (e.g. just C sources).
Current mappings: <%=SearchHelper.getFileTypeDescriptions().toString()%>

The term (phrases) can be boosted (making it more relevant) using a caret ^ , e.g. help^4 opengrok - will make term help boosted

Opengrok search is powered by Lucene, for more detail on query syntax refer to Lucene docs.

Intelligence Window

Key "1" toggles Intelligence Window. It gives the user many helper actions on the last symbol pointed by the mouse cursor.

Intelligence window screenshot
Symbol Highlighting

Keys "2", "3", ..., "7" toggles highlighting of the last symbol pointed by the mouse cursor. This functionality is also accessible via the Intelligence Window.

Key "8" toggles un-highlighting all symbols. This functionality is also accessible via the Intelligence Window.

symbol highlighting screenshot

You can close the intelligence window either by mouse in the right upper corner or by keyboard with "Esc" key.

Symbol jumping

By 'n' for next and 'b' for back you can jump between the symbols easily only with keyboard. When there is no symbol highlighted then the jump is made to the next symbol in the file from the current one. If you have highlighted a specific symbol then the jump is done only among the highlighted symbols regardless the color of the symbol.

Diff jumper

The OpenGrok also provides an easy way how to jump through the large diffs finding the interesting pieces of code. In the diff mode you can enable diff jumper by hitting the "jumper" button.

diff jumper screenshot
Mouse and keyboard navigation

You can then use your mouse to intuitively navigate yourself through the diff. Also there is a convenient shortcut for moving on your keyboard, you can use 'n' for next and 'b' for back to jump over to the next chunk. This is available even when the jumper window is not opened.

screenshot of diff jumper in action
<% /* ---------------------- help.jsp end --------------------- */ %><%@ include file="foot.jspf" %>