cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene Searches involving the dash (-) character

niele
Champ on-the-rise
Champ on-the-rise
I'm doing some queries and processing using the Javascript Console and I've run into some trouble when my search term includes a dash (-) character. 

Here's a simplified example:

var rfx = 'RFT-TS-16-16';
var results = search.luceneSearch("@cm\\:name:\"" + rfx + "\"");

What I would like are matches where the name contains exactly "RFT-TS-16-16" but it's returning extra results such as "RFT-TS-16-12" so I'm not quite understanding how it is working.  I read that the escape character is '\' but searching for 'RFT\-TS\-16\-16" returns identical results.  Could someone please enlighten me?

Thanks,
Neil
1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator
Hello,

very likely this is the result of tokenisation during indexing and searching. The dash character is a natural place to perform tokenisation. Since the tokens "RFT", "TS" and "16" are contained in the result it is returned - even if you have the token "16" twice in your search. To look for exact matches, the query should likely use =@cm:name:"RFT-TS-16-16". I strongly advise to NOT use legacy luceneSearch anymore and instead opt for query() with search language fts-alfresco. The lucene language has various drawbacks, especially that it doesn't support the "transactional metadata query" feature added in 4.2.

Regards
Axel

View answer in original post

2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

very likely this is the result of tokenisation during indexing and searching. The dash character is a natural place to perform tokenisation. Since the tokens "RFT", "TS" and "16" are contained in the result it is returned - even if you have the token "16" twice in your search. To look for exact matches, the query should likely use =@cm:name:"RFT-TS-16-16". I strongly advise to NOT use legacy luceneSearch anymore and instead opt for query() with search language fts-alfresco. The lucene language has various drawbacks, especially that it doesn't support the "transactional metadata query" feature added in 4.2.

Regards
Axel

niele
Champ on-the-rise
Champ on-the-rise
Thanks so much for the quick response and suggestions.  I'm now using search.query with fts-alfresco and it's working perfectly with wildcards:

var searchObj = {
   query: 'PATH:"/app:company_home/st:sites/cm:grey-county/cm:documentLibrary//*" AND @cm\:name:"*RFT-TS-16-16*"',
   language: 'fts-alfresco'
}

var results = search.query(searchObj);

Neil