cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene case-sensitive Search

tremalnaik
Champ in-the-making
Champ in-the-making
Hi,

I'm triying create a Lucene query which has te case-sensitive propertie. My example is like this:


String luceneQuery = "PATH:\"/app:company_home//*\" " + "AND @cm\\:name:\"" +name+"\"";
               
Query query = new Query(Constants.QUERY_LANG_LUCENE,luceneQuery);
                        
QueryConfiguration q = new QueryConfiguration();

QueryResult queryResult = repositoryService.query(spacesStore, query, true, q);

Where "name" is the word of search. Now, if "name" is equal to test the query returns elements like

  • Test
  • Test1
  • tEst
  • etc
Exists some meaning to make the Lucene case-sensitive? Thanks
5 REPLIES 5

openpj
Elite Collaborator
Elite Collaborator
I think that it depends on the Lucene Analyzer used to create index values for a specific locale.

In Alfresco you can configure analyzers in the following path:
alfresco.war/WEB-INF/classes/alfresco/model/dataTypeAnalyzers_<LOCALE>.properties
For each locale setting you will find a properties file to change the Lucene class dedicated to tokenize words.
Remember that if you change one of these analyzers you have to re-index all the content before trying to execute searches.

Hope this helps.

tremalnaik
Champ in-the-making
Champ in-the-making
Thank you. I will try

himvj
Champ in-the-making
Champ in-the-making
I am using English locale. What configuration should i use to make the indexing case insensitive ??

The current properties file contains the following:-
d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser
d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser

I am using alfresco3.4d

Thanks for your help!

t_sato
Champ in-the-making
Champ in-the-making
Hi,

Take a look at AlfrescoStandardAnalyser source code, then you find the following method.

    public TokenStream tokenStream(String fieldName, Reader reader)
    {
        TokenStream result = new StandardTokenizer(reader);
        result = new AlfrescoStandardFilter(result);
        result = new LowerCaseFilter(result);
        result = new StopFilter(result, stopSet);
        result = new ISOLatin1AccentFilter(result);
        return result;
    }

LowerCaseFilter does the lower-casing job.

So I think you can copy, customize(comment it out), configure, and deploy to make it work.

cyr
Champ in-the-making
Champ in-the-making
hi!
I'm using Alfresco 4.0.2, and i wrote a web script to fetch files in alfresco via Lucene search engine.
my code is : var result = search.luceneSearch("@cm\\:name:*"+args.sSearch+"*.pdf OR @cm\\:name:*"+args.sSearch+"*.txt");
But it seems that Lucene in case sensitive.
How can i do to make Lucene to be case insensitive?

Thanx.