News & Announcements
What's New
Hyland Announcements
Community News
Blogs & Forums
Content Innovation Cloud
OnBase
Alfresco
Nuxeo
Perceptive Content
Hyland Cloud
Additional Products
Industry Solutions
Resources
Welcome to Hyland Community
Product Resources
Support Resources
Services Resources
Hyland Cloud
All Hyland Resources
Groups
Partners
Help
Home
Alfresco
Alfresco Archive
Lucene Searches involving the dash (-) character
niele
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
Find more posts tagged with
Accepted answers
afaust
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
All comments
afaust
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
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