| Name | Advanced Search |
|---|---|
| Vendor | Adaptavist.com Ltd (Website) |
| Authors | Dan Hardiker, Guy Fraser |
| Homepage | http://confluence.atlassian.com/display/CONFEXT/Advanced+Search+Plugin |
| Issue Management | n/a |
| Continuous Integration | n/a |
| Categories | Content Macros |
| Most Recent Version | 1.0.4 |
| Availability | Confluence v2.3-dr1 to v2.10 |
| State | Stable |
| Support |
|
| License | Freeware / Open Source (BSD) |
| Price | Donate |
| Release Docs | http://confluence.atlassian.com/display/CONFEXT/Advanced+Search+Plugin |
| Java API Docs | n/a |
| Download Source | http://svn.atlassian.com/svn/public/contrib/confluence/advanced-search-plugin/tags/1.0.4/ |
| Download JAR | adaptavist-advanced-search-1.0.4.jar |
| This plugin now accessible through the Confluence Repository Client. |
Confluence v2.2.x concatonates query terms using OR, where as Confluence v2.3.x and beyond uses AND. |
Description
This plugin provides a set of macros utilising DWR (AJAX) searching capabilities. These macros center around providing a form-based interface for building search queries, the output is dynamically sortable and can be customised.
The data from the fields form generate a search query which is then processed by lucene via the Confluence API, with all the terms (each field) being AND'ed together (so all terms must match, not any). There is no paging on the results, and the results can show the rating of each blog / page - however showing the rating column will slow down the showing of the results somewhat. The rating is based on the Rate Macro.
Automatic running queries is also possible so that the search form submits the default values and returns the results automatically. The search form can also be hidden, if desired.
Usage
Only a single {search-form} and {search-results} can be used on a page in any order. Both must be present to operate properly.
{search-form}
This defines the seach criteria part of the page, which can optionally be hidden. It has a body that encapsulates the {search-input}, {search-select} and {search-submit} macros which define any number of search criteria or filters.
| Parameter | Description | Type | Default | Required |
|---|---|---|---|---|
| autoSubmit | Submit the form as soon as the page loads (providing default results) | boolean | false | |
| hidden | Hide the form from view (only useful with autoSubmit) | boolean | false | |
So, let's take a look at the macros that go in the body of the search-form (an example is shown lower down this page)...
{search-input}
This provides an input field synonymous to a HTML input field and has no body.
| Parameter | Description | Value | Default | Required |
|---|---|---|---|---|
| match | Type of Search Field | string (label, metadata, query) | none | |
| metadataKey | Metadata Key - only valid for match=metadata | string | none | |
| type | Type of Field | string (text / checkbox / hidden) | none | |
| value | Value of the Field | string | none | |
| checked | Inital State - only valid for type=checkbox | boolean | false | |
As you can see, you can create hidden fields - this is really useful if there is a filter you always want to apply to the search form but don't want users to see.
{search-select}
This provides an select field (drop-down list) synonymous to a HTML select field, with options defined in it's body by the {search-option} macro.
| Parameter | Description | Value | Default | Required |
|---|---|---|---|---|
| match | Type of Search Field | string (label, metadata, query) | none | |
| metadataKey | Metadata Key - only valid for match=metadata | string | none | |
| nullLabel | Label of the "unanswered" option | string | no "unanswered" option | |
{search-option}
This provides an option field synonymous to a HTML option field, its body is wiki rendered and is the outputted label for the option.
| Parameter | Description | Value | Default | Required |
|---|---|---|---|---|
| value | Value of the Field | string | empty | |
| selected | Is this Option Selected | boolean | false | |
{search-submit}
You MUST include a search-submit within the search-form if you wish your users to be able to manually submit the search. If you hide the search form and set it to auto submit, then this is not needed.
This provides a submit button. You need one of these for the form to work!
| Parameter | Description | Value | Default | Required |
|---|---|---|---|---|
| default | Label for the Button | string | Submit | |
{search-results}
This provides the target for search results to goto, it also configures how the search results are displayed.
- Types - There are 4 content types you can search for currently. You specify them as a comma separated list and any of the specified content types are included in the results. The 4 content types are: page, blogpost, userinfo and spacedesc.
- Fields - There are 6 fields, and can be displayed in any order - however title must always be display. They can also be renamed:
rating,title!My Title,author
That would put the fields in that order, renaming the title field to "My Title".
- Excerpts - If shown, the contents of the {excerpt} macro are used first and then it falls back on the the content excerpt used in the standard search results.
- Ratings - If the rate macro is use (or has been in the past) and the page has ratings, then an average is found. If the rateThreashold (defaulting at 5) isn't met (i.e. if there haven't been 5 people rating this content) then it uses 0. If there isn't any rate data then it defaults to 0 as well. NOTE: If the content has been rated in the past, and the rate macro is then removed - the rating data will sill remain and will still be used by this plugin. This can be worked around by detecting the presence of a {rate} macro first in the content - however this work around isnt in effect yet. Please let me know if this is needed.
| Parameter | Description | Value | Default | Required |
|---|---|---|---|---|
| fields | The selection, order and naming of the fields | string | title!Resource,rating,creation,modified,author,space!Partner | |
| types | The content types to search for | string | page,blogpost | |
| showExcerpts | Should I show excerpts? | boolean | true | |
| sortField | The fields to sort on initially. | string (a field from fields) | title | |
| sortDir | The direction to sort on initially. | string (asc / desc) | asc | |
| maxResults | How many results should I truncate to? (users will be warned in the case of more results than shown) | int | 20 | |
| rateThreshold | How many ratings are needed before the average is used? | int | 5 | |
| debug | Should I show the query I generated for debugging? | boolean | false | |
Tutorial
To begin with you are going to want to have a basic search form:
{search-form}
{search-input:type=text|match=query}
{search-submit:Search}
{search-form}
{search-results}
This about as basic as it gets, pretty much emulating what the normal Confluence search does - except limiting results to pages and blog posts. From here we can built up the search so that it is tailored to our needs. I now have the following criteria:
- I want to set the default value of the query to repository plugin, as if that was typed into the search engine.
- I want to only return content that has the searchable label - but this shouldn't be displayed as an option.
- I want the search to be run automatically with the defaults above.
{search-form:autoSubmit=true}
{search-input:type=text|match=query|value=repository plugin}
{search-input:type=hidden|match=label|value=searchable}
{search-submit:Search}
{search-form}
{search-results}
Great! I would like to customise the results though, so that it shows the rating, author, title, then space. I want to sort by rating descendingly. I also want the title column to be called Content Title instead.
{search-results:fields=rating,author,title!Content Title,space|sortField=rating|sortDir=desc}
Advanced Example
The following provides a general search term box, with checkboxes for searching for different preset keywords as well as an advanced one for searching for one label but not another.
{search-form:autoSubmit=true}{search-input:type=text|match=query}
{search-input:type=checkbox|match=query|value=label:( +global?agency-home ) NOT label:( +global?hidden )} Normal label "agency-home" but not "hidden" label
{search-input:type=checkbox|match=query|value=Nordic Scandinavia "Northern Europe" Denmark Finland Iceland Norway Sweden} Nordic States
{search-input:type=checkbox|match=query|value="European Union" Germany France "United Kingdom" UK Italy Spain Poland Romania Netherlands Greece Portugal Belgium Czech "Czech Republic" Hungary Sweden Austria Bulgaria Slovakia Denmark Finland Ireland Lithuania Latvia Slovenia Estonia Cyprus Luxembourg Malta} European Union
{search-input:type=checkbox|match=query|value=Germany Switzerland Liechtenstein Slovakia Poland Czech "Czech Republic" Austria Hungary Slovenia} Central Europe
{search-input:type=checkbox|match=query|value=Burundi Comoros Djibouti Eritrea Ethiopia Kenya Madagascar Malawi Mauritius Mozambique Réunion Reunion Rwanda Seychelles Somalia Uganda "United Republic of Tanzania" Tanzania Zambia Zimbabwe|checked=true} Eastern Africa
{search-submit:Search}
{search-form}
{search-results:types=page,blogpost,userinfo,spacedesc|rateThreshold=0|maxResults=50|fields=space!Bubble,title,rating,author|sortField=rating|sortDir=desc|showExcerpts=true|debug=true}


Comments (94)
Sep 26, 2006
dieter says:
Nice macro. Is it possible to have an example using metadata / rate macro? Is i...Nice macro. Is it possible to have an example using metadata / rate macro?
Is it possible:
If you have for example 5 pages with rate plugin, that are labeled = TEST.
to order these 5 ratings on a summary page? TITLE, AUTHOR, RATING (ordered by rating)
How to? Thanks.
Sep 26, 2006
Guy Fraser says:
That's almost exactly what the tutorial does, however, for avoidance of doubt......That's almost exactly what the tutorial does, however, for avoidance of doubt...
{search-form:autoSubmit=true|hidden=true} {search-input:type=hidden|match=label|value=test} {search-form} {search-results:fields=title,rating,author|sortField=rating|sortDir=desc}That will automatically submit the search for things with label of "test" (labels are always lowercase) without displaying the search form so only the results are shown. The resuls show a table of title, rating and author with the default sort set to rating but you can click any heading on the table to change sort order.
Sep 26, 2006
Guy Fraser says:
oops - missed the search-submit: {search-form:autoSubmit=true|hidden=true} ...oops - missed the search-submit:
{search-form:autoSubmit=true|hidden=true} {search-input:type=hidden|match=label|value=test} {search-submit:Search} {search-form} {search-results:fields=title,rating,author|sortField=rating|sortDir=desc}Sep 26, 2006
Dan Hardiker says:
If autoSubmit doesnt work without a submit button - that's a bug.If autoSubmit doesnt work without a submit button - that's a bug.
Sep 26, 2006
Guy Fraser says:
Possibly, I was always under the impression that the search button is always req...Possibly, I was always under the impression that the search button is always required...
Sep 27, 2006
dieter says:
It still doesn't work? I always get "There were no results for your search crite...It still doesn't work? I always get "There were no results for your search criteria."
I tried the basic search macro to test: (attached image here)
but again: "There were no results for your search criteria."
There are some dependicies for this plugin?
Sep 27, 2006
dieter says:
i meant the basic search form instead of macroi meant the basic search form instead of macro
Sep 27, 2006
Dan Hardiker says:
In the {search-results} set debug=true. This will output the search query used -...In the {search-results} set debug=true. This will output the search query used - try this in the Confluence search.
Please paste the search query here and I'll try to help.
Sep 27, 2006
dieter says:
debugging: Query: type page blogpost ) AND ( test ) in confluence search: S...debugging:
Query: type
page blogpost ) AND ( test )
in confluence search:
Searched for type
page blogpost ) AND ( test ) in Global Spaces
Matching labels:test
Related Labels:(None)
Sep 27, 2006
Dan Hardiker says:
and if you do a confluence search for just "test" does it yeild any results? If ...and if you do a confluence search for just "test" does it yeild any results? If not, then this macro wont either, as it's based on the confluence search engine!
Sep 28, 2006
dieter says:
For confluence search (search box on right top of screen):it returns the label "...For confluence search (search box on right top of screen):it returns the label "test", see also last comment, and if you click you see all the pages labelled with the label "test"
Sep 29, 2006
Juan Leon says:
I found the example in Dan's tutorial of how to create a NOT condition especiall...I found the example in Dan's tutorial of how to create a NOT condition especially helpful:
{search-input:type=checkbox\|match=query\|value=label:( \+global?agency-home ) *NOT label:(* \+global?hidden )} Normal label "agency-home" but not "hidden" labelHow can I create a similar effect without the checkbox? What I'd like to do is (invisibly) place a condition on all searches run by the user so that items with a certain label are not returned--or at least not displayed.
Sep 29, 2006
Guy Fraser says:
type=hiddentype=hidden
Sep 29, 2006
Hitesh Seth says:
We are still using Confluence 2.1.x. Is it possible to leverage this plugin in a...We are still using Confluence 2.1.x. Is it possible to leverage this plugin in a confluence 2.1.x environment?
Here is the Error that I get when trying to install it
The following error(s) occurred:
Thanks
Sep 30, 2006
Dan Hardiker says:
I'm afraid not - as shown in the Availability table at the top, this is only ava...I'm afraid not - as shown in the Availability table at the top, this is only available on Confluence v2.2.1a and above as there were some important plugin classloader changes performed in that version.
Is there any reason you haven't upgraded to 2.2.x yet?
Oct 04, 2006
Stuart Donovan says:
Can I restrict the search to one or more spaces?Can I restrict the search to one or more spaces?
Oct 26, 2006
Dan Hardiker says:
Not currently.Not currently.
May 09, 2008
Eric Banford says:
You can search across different spaces like this: {search-form} {search-input:...You can search across different spaces like this:
{search-form}
{search-input:type=text|match=query}
{search-input:type=hidden|match=query|value=spacekey:SPACE1 OR spacekey:SPACE2}
{search-submit:Search}
{search-form}
{search-results}
Does anyone see any issues with this?
Oct 17, 2006
Jesse A Crowley says:
Does anyone have a good example of the search-select option?Does anyone have a good example of the search-select option?
Oct 26, 2006
Dan Hardiker says:
{search-form} {search-select:match=query} {search-option:value=hello}Say ...{search-form} {search-select:match=query} {search-option:value=hello}Say Hello{search-option} {search-option:value=goodbye}Say Good Bye{search-option} {search-option:value=blahblah}Bleh!{search-option} {search-select} {search-submit:Search} {search-form}Nov 10, 2006
Michael says:
Can i display the author name of a page ? ... The author paramater of search-re...Can i display the author name of a page ? ...
The author paramater of search-result returns the name of the last modifier and not the author :/
Nov 10, 2006
Dan Hardiker says:
Hi, Unfortunately that is hard-coded in; you would need to check out the source...Hi,
Unfortunately that is hard-coded in; you would need to check out the source and modify the SearchDWR class, then use maven to rebuild it.
–
Dan Hardiker
Adaptavist.com Ltd
Nov 17, 2006
Charles Hill says:
Is it possible to have a NOT expression on the metadataKey field as well?Is it possible to have a NOT expression on the metadataKey field as well?
Dec 14, 2006
Paul Carruthers says:
Just a quick question. Is it possible to limit the search to something specific,...Just a quick question. Is it possible to limit the search to something specific, such as space labels or the spacedesc? Want to build a custom page using this instead of the general Confluence serach.
Cheers,
Paul.
Dec 18, 2006
Mert Caliskan says:
how can i search mails too with this advanced search plugin?how can i search mails too with this advanced search plugin?
Dec 21, 2006
Régis CHOURAQUI says:
Nice plugin. Someone asked for a search restricted by space, I just to add my i...Nice plugin.
Someone asked for a search restricted by space, I just to add my interest for this option.
Thanks.
Régis.
Jan 11, 2007
Régis CHOURAQUI says:
Hi, Just one request : Can you add "attachments" in "types" of search su...Hi,
Just one request :
Can you add "attachments" in "types" of search supported ?
For the moment I can't see any answer about .doc .xls .pdf . ..... It's quite a problem.
Thanks for your help.
Régis
Jan 23, 2007
Grigorio V. Moshkin says:
Hi, I have a trouble: I've installed the plugin. Confluence said in Administra...Hi, I have a trouble:
I've installed the plugin. Confluence said in Administration->plugins that "Adaptavist Advanced Search
All modules enabled."
I type a tutorial search form macro (or another, more complicated macro) in my own page edit tab, then press "Save" and switch to view page tab.
But I see the submit button being ALWAYS disabled. So I can not press it to start search itself.
And Confluence log file "atlassian-confluence.log" contains the following lines:
2007-01-23 12:42:34,062 INFO [com.atlassian.confluence.lifecycle] contextInitialized Starting Confluence 2.2.9 (build #527)
2007-01-23 12:43:59,750 ERROR [ltd.getahead.dwr.DWRServlet] error Missing config file: advanced-search-dwr.xml
2007-01-23 12:43:59,750 WARN [getahead.dwr.impl.DefaultProcessor] warn Page not found (/advanced-search/dwr/engine.js). In debug/test mode try viewing /[WEB-APP]/dwr/
2007-01-23 12:43:59,859 WARN [getahead.dwr.impl.DefaultProcessor] warn Page not found (/advanced-search/dwr/interface/SearchDWR.js). In debug/test mode try viewing /[WEB-APP]/dwr/
2007-01-23 12:44:22,000 WARN [getahead.dwr.impl.DefaultProcessor] warn Page not found (/advanced-search/dwr/engine.js). In debug/test mode try viewing /[WEB-APP]/dwr/
2007-01-23 12:44:22,062 WARN [getahead.dwr.impl.DefaultProcessor] warn Page not found (/advanced-search/dwr/interface/SearchDWR.js). In debug/test mode try viewing /[WEB-APP]/dwr/
So, does anybody know what goes wrong?
Sincerely yours,
Grigorio V. Moshkin,
Garant Service - Moscow State University http://www.garant.ru
Feb 22, 2007
Audrey M. Schaffer says:
Hello - I'm having trouble using the "NOT label" command. I want the search to ...Hello - I'm having trouble using the "NOT label" command.
I want the search to run and not consider pages which I have labeled "navigation" (since these are the pages that make up my navigation bar and do not have substantive content). I tried to copy the example above, and wrote the command as:
{search-input:type=hidden\|match=query\|value=NOT label:navigation}But, what this has done is stopped returning any results for (I think) any pages, even those without any labels whatsoever. If I remove this line, I get search returns of both my navigation pages and all other pages.
What am I doing wrong? Thanks for any help in advance!
-Audrey
Feb 22, 2007
Dan Hardiker says:
Please add "debug=true" to the {search-results} macro, which will output the que...Please add "debug=true" to the {search-results} macro, which will output the query which it is building. This query string can be used in the standard Confluence search engine (that's what it uses as the back-end after all). You can then fix the query string, and reverse engineer the changes as appropriate.
In general, debugging starts with working out the query you want it to end up with, and then work out how to get that generated.
Feb 26, 2007
Audrey M. Schaffer says:
Dan, I've been working with the debugger and I have shed some more light into t...Dan,
I've been working with the debugger and I have shed some more light into the situation, but still no solution.
In using the simple search, it seems that a command such as: "Germany AND NOT navigation" will return the search results I want. But the command "Germany AND (NOT navigation)" will return nothing (same results as I described above). This is only a problem because the Advanced Search only inputs individual terms surrouned by parenthesis.
Is there a way to remove the parens in the advanced search?
-Audrey
Feb 26, 2007
Dan Hardiker says:
Hrm - in order to deal with the multiple concatenations, it adds in the parenthe...Hrm - in order to deal with the multiple concatenations, it adds in the parenthesis. The plugin would need to be modified to allow them to be removed.