cancel
Showing results for 
Search instead for 
Did you mean: 

Help with searching

atariq
Champ in-the-making
Champ in-the-making
I recently installed the new release of Alfresco 2.0 and am giving it a test whirl and I have come to understand that the search engine supports Lucene. I must admit here that I have no prior knowledge in Lucene queries and I was hoping someone would be able to help me with an issue in searching that I'm currently trying to figure out.

I have a large number (> 1000) of docs uploaded onto an Alfresco space and so the search engine would definitely come handy. I'm trying to figure out how to type in a query such that only documents that contain ALL the words in the search are returned and not any documents that contain only one or a few of the words.

e.g.:

File 1 contains the word "boo"

File 2 contains the words "boo shoo foo goo"

I would like the search query, 'boo goo', to return ONLY File 2 as it is the only file that contains both the word 'boo' and 'goo'.

Currently, the search returns BOTH File 1 and File 2 because both files contain the word 'boo'.

How can I work around this? Any help is appreciated! Thanks!
3 REPLIES 3

dnind
Champ in-the-making
Champ in-the-making
With the default search setting you are saying give me all the documents with either "boo" OR "shoo" in them.  As a result the two files are returned.

If you want both terms to be in the documents returned, but not necessarily as a phrase, use +boo +shoo - this is saying give you all the documents with both boo AND shoo in them.

If you want the phrase "boo shoo" then you need to put the query in quotes - "boo shoo" - this says find the documents with the exact phrase "boo shoo" in it - should only return one result.

If you want to return documents with both "boo" and "shoo" in them by default, you may want to change the setting in your web-client-config-custom.xml file as follows:

<config>
    <client>
     ……
     <!– enable AND for simple and advanced search by default –>
     <search-and-terms>true</search-and-terms>
     ……
    </client>
</config>

The wiki gives some technical information on how search is setup at http://wiki.alfresco.com/wiki/Search

Version 2 of Alfresco has upgraded to Lucene v2.0.0 ( http://wiki.alfresco.com/wiki/Release_2.0 )

Hope this helps.

atariq
Champ in-the-making
Champ in-the-making
Thanks, dnind, that worked just fine! Smiley Happy

I've been fooling around with Lucene queries and I had been trying to use the AND operator (e.g boo AND shoo) but it would keep breaking with a 'Query could not be parsed' error. Writing it in this form '+boo +shoo', however, worked like a charm.

With respect to the code snippet you posted for default searches (something that would really help), I'm still trying to get a hang of how the code works and how the wiki can help. It's all a little helter skelter to me, now, I'm afraid. I had been looking at the wiki page but it almost seems as if it discusses hard coded searches – not something practical, for obvious reasons. Would I have to put your <config> …. </config> code within an advanced search tab or is the block on its own?

In any case, I'm going to get my hands dirty some more. Thanks again for your help on this!

dnind
Champ in-the-making
Champ in-the-making
The basics for configuration of the web client (for Tomcat). 

The default web client configuration file - web-client-config.xml - is located at <alfresco>/tomcat/webapps/alfresco/WEB-INF/classes/alfresco  You can see in this file the settings you can change.

If you want to over-ride any of these settings you need to include them in the web-client-config-custom.xml file located at <alfresco>/tomcat/shared/classes/alfresco/extension

It is good practice to do this as the files in the /tomcat/shared folder are not altered when you upgrade Alfresco or if the alfresco.war file is redeployed (if this happens, it replaces all the files under the webapps/alfresco folder).

So in the search example the default is set in <alfresco>/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/web-client-config.xml  to:

<config>
  ……….
    <client>
      ……….
       <!– set this value to true to enable AND text terms for simple/advanced search by default –>
         <search-and-terms>false</search-and-terms>
      ……..
   </client>
  ……..
</config>

To over-ride this so that it is enabled change <alfresco>/tomcat/shared/classes/alfresco/extension/web-client-config-custom.xml to include:

<config>
  ……….
    <client>
      ……….
       <!– enable AND text terms for simple/advanced search by default –>
         <search-and-terms>true</search-and-terms>
      ……..
   </client>
  ……..
</config>

Note:  You need to restart Alfresco for these changes to take effect.

Further resources that contain some good information to get started with (and can explain it better than I can):

Web Client Configuration Guide at:
http://wiki.alfresco.com/wiki/Web_Client_Configuration_Guide

Web Client Customisation Guide
http://wiki.alfresco.com/wiki/Web_Client_Customisation_Guide

If you are serious about using Alfresco I would highly recommend the book Alfresco Enterprise Content Management Implementation if your just getting started, particularly Chapter 7 on extending the content model:
http://wiki.alfresco.com/wiki/Alfresco_Books