[opencms-dev] Choose the directory to start the search

Jonathan Woods jonathan.woods at scintillance.com
Thu Sep 14 19:24:02 CEST 2006


OpenCms does index a Lucene Field specifically for the purpose of carrying
out searches on the basis of partial folder/resource paths, so I would have
though you could coerce the OpenCms search API into using this to carry out
your own folder restrictions as part of queries.

The Field in question is called I_CmsDocumentFactory.DOC_ROOT (which
evaluates to "root") and it comprises a space separated sequence of path
fragments, each path fragment being supplemented by the String "@o.c" to
fool the Lucene QueryAnalyzer into allowing phrase queries.  Take a look at
source code to see what I mean.  I guess if you stick to the OpenCms search
API, you could add a prefix clause on this Field to the String passed to the
QueryAnalyzer.

Of course, it is nicer to have direct access to Lucene search indices and
Queries, but getting that takes a bit of work.

Jon

-----Original Message-----
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Christian Steinert
Sent: 14 September 2006 12:40
To: The OpenCms mailing list
Subject: Re: [opencms-dev] Choose the directory to start the search

maria.freixes_graells at alcatel.es schrieb:
> Hello everybody!!
>
> This is a question that I made a few days ago, please, if someone has 
> an idea to implement this, It would be great!
> The question is that each time I launch a search, always the tool scan 
> all the directories in our structure, but I would like an option to 
> add into my search, in order to implement the facility to choose the 
> directory for starting the search.
>
> Any idea?
>
> Maria
I don't know if you can search only some files of your index. I think you
have to create a separate search index for each section that you want to
make searchable.

Opencms supports this very well:
- You create one index source for each section.
- You combine one or more of these index sources are into a search index.
You can re-use one index source in several search indexes, if you like.
- Then in your search form you can present a simple drop-down - list, where
the user can select one of the indexes you have defined. The selected index
will tell opencms which search index should be used. The name of that
parameter is "index" and there you just have to set the name of one of your
indexes - as you have named it in the opencms search configuration.

I hope that this is a bit clear new. I found it a bit indirect when I
defined my own indexes, but if you play around with the search configuration
and try to create some index sources and indexes, I hope it becomes more
clear.

Regards.
christian




More information about the opencms-dev mailing list