Querying ======== .. contents:: Table of Contents INDICA allows you easily create powerful queries. The creation of queries can be done in multiple ways: * Writing queries by hand * Using the advanced query builder Writing queries --------------- INDICA provides a rich query language, giving its users a flexible and advanced way to search through large amounts of documents. The search bar allows multiple ways of querying. It is possible to type in search terms and manipulate the way the query interpreter deals with the query. INDICA allows the following query manipulations: Search By ********* Users can search for keywords inside the name, path, content, metadata or summary of the document. .. thumbnail:: /media/img/user/search/querying/searchBy.png Exact match ***************** Exact match checkbox allows for quick term or phrase searches. It only supports simple text and Filters, no query modifiers such as Boolean Operators, Fuzzy Searches, Wildcards, etc. are supported . After the checkbox is ticked, whole text will be treated as a single search term. Any advanced terms will be ignored! See example below .. thumbnail:: /media/img/user/search/querying/exactMatch.png Terms and Phrases ***************** A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases. A single term is a single word such as ``test`` or ``hello``. A phrase is a group of words surrounded by double quotes such as ``"hello test"``. Boolean Operators ***************** Boolean operators allow terms to be combined through logic operators. INDICA supports the following operators: * | **AND** | The ``AND`` operator matches documents where both terms exist anywhere in the text of a single document. The symbol ``&&`` can be used in place of the word ``AND``. | To search for documents that contain "jakarta apache" and "Indica search" use the query ``"jakarta apache" AND "INDICA search"`` * | **"+"** | The ``+`` operator requires that the term after the ``+`` symbol exist somewhere in a field of a single document. | To search for documents that must contain "jakarta" and may contain "INDICA" use the query ``+jakarta INDICA`` * | **OR** | The ``OR`` operator is the default conjunction operator. | This means that if there is no boolean operator between two terms, the ``OR`` operator is used. | The ``OR`` operator links two terms and finds a matching document if either of the terms exist in a document. | The symbol ``||`` can be used in place of the word ``OR``. | To search for documents that contain either "jakarta apache" or just "jakarta" use the query ``"jakarta apache" jakarta`` or ``"jakarta apache" OR jakarta``. * | **NOT** | The ``NOT`` operator excludes documents that contain the term after ``NOT``. | The symbol ``!`` can be used in place of the word ``NOT``. | To search for documents that contain "jakarta apache" but not "INDICA search" use the query ``"jakarta apache" NOT "INDICA search"`` .. note:: The NOT operator cannot be used with just one term. For example, the following search will return no results: ``NOT "jakarta apache"`` * | **"-"** | The ``-`` operator excludes documents that contain the term after the ``-`` symbol. | To search for documents that contain "jakarta apache" but not "INDICA search" use the query ``"jakarta apache" -"INDICA search"`` .. important:: Boolean operators **must be** ALL CAPS Grouping ******** INDICA supports using parentheses to group clauses to form sub queries. This can be very useful if you want to control boolean logic for a query. To search for either "jakarta" or "apache" and "website" use the query ``(jakarta OR apache) AND website``. This eliminates any confusion and makes sure you that "website" must exist and either term "jakarta" or "apache" may exist. Range Searches ************** 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. Example: ``date:[2002-01-01 TO 2003-01-01]`` This will find documents whose date fields have values between 2002-01-01 and 2003-01-01, inclusive. To perform a Range Query and exclude the upper and lower bound, use ``{`` and ``}`` instead of ``[`` and ``]``. The inclusive and exclusive range characters can also be mixed: Example: ``date:{2002-01-01 TO 2003-01-01]`` Wildcards ********* Wildcard searches can be done with two operators: * | **"?"** | A question mark will allow different characters at that specific position in the word. | Example: ``?est`` | INDICA will return words like "rest", "test", "nest" * | **"*"** | An asterisk places after (part of) the word, will enforce the presence of that (part of) the word in the results and then expand the word. | Example: ``test*`` | INDICA will return words like "testing", "testresult", "testcase" Fuzzy Searches ************** A 'tilde' (``~``) after the term will imply that the term might be spelled in different ways. The similarity can be changed by adding a value between 0 and 1. A value closer to 1 will return words that are very similar. The value 0.5 cannot be used. Word Distance Searches ********************** Distance searches use the 'tilde' ``~`` as well. It can be used in the following format: ``"testing Europe"~10`` This will search for the two terms "testing" and "Europe" with a maximum of 10 words in between. It will return results like: ``Testing some pieces advanced software is done routinely in Europe`` and ``The developer is doing some testing in Europe`` Boosting terms ************** INDICA provides the relevance level of matching documents based on the terms found. To boost a term use the caret ```^``` symbol with a boost factor (a number) at the end of the term you are searching. The higher the boost factor, the more relevant the term will be. Boosting allows you to control the relevance of a document by boosting its term. For example, if you are searching for ``jakarta apache`` and you want the term "jakarta" to be more relevant, boost it using the ``^`` symbol along with the boost factor next to the term. You would type: ``jakarta^4 apache``. This will make documents with the term jakarta appear more relevant. You can also boost Phrase Terms as in the example ``"jakarta apache"^4 "Indica search"``. By default, the boost factor for each term or phrase is 1. Although the boost factor must be positive, it can be less than 1 (e.g. 0.2) Advanced query builder ---------------------- The advanced query builder is a visual tool to create powerful queries. The tool can be found when clicking the "Advanced Query" button next to the "Query to CSV" button. .. thumbnail:: /media/img/user/search/querying/advancedQueryButton.png A new panel will open: .. thumbnail:: /media/img/user/search/querying/advancedQueryOpened.png A few options can be filled in here: * **Match Type** The "Match Type" determines that either "All" or "Any" condition of the query needs to be true. Either all conditions in the query need to be true, or any condition needs to be true. * **Add rule** It's possible to filter on a few different items: * Type * Path * Tags * Info * Collection * Workflow * Privacy * Dupes * Size * Document ID * Content * File name * Date (yyyymmdd) Select a filter within the input field left of the *Add Rule* button which you wish to query on, click on add rule to add this to the query. The rule will be added underneath your latest rule. Here you can also choose per rule if you wish to add this as an 'AND' or 'OR' query. Clicking on the 'X' next to the item will delete the rule. * **Add group** The *Add Group* button is only available at the top of the Advanced Query Builder next to the *Add Rule* button. This will add a new group underneath the existing group. Groups can be visually distinguished by the new 'Match Type' filter and the horizontal line underneath it. * **Build** The query can always be previewed next to the buttons at the bottom. With the *Build* button however, you're able to build the query in the search bar at the top. Please be aware that this building is necessary if you wish to save the query! * **Search** Execute the search with the previewed query. .. note:: The query needs to be build in order to save it correctly as a saved query! * **Reset** Reset the whole query. This will empty both the search input field, search results and the advanced query preview. Use the drop-down menu to select a field. Click "Add Rule" to add a new rule for that field. .. thumbnail:: /media/img/user/search/querying/advancedQuery1Rule.png In case multiple options are available for the selected field, a list will be shown. Use CTRL+click to select multiple options. A choice can also be made between "All" to query on all the selected conditions, or "OR" to query on any of the selected conditions. Escaping special characters --------------------------- In some cases, the search term may use one of the Query Engine's special characters. If that's the case, the character needs to be 'escaped' so the engine will interpret the character as a literal character. The following characters are special characters:: + - && || ! ( ) { } [ ] ^ " ~ * ? : \ To escape these character place a backslash ("\\") before the special character.