cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene query doesn't work right?

jtorres
Champ in-the-making
Champ in-the-making
Hi people:

I'm trying to search a node by its name. If I find by exact name the query works perfect:

"@\\{http\\://www.alfresco.org/model/content/1.0\\}name:'+name

However if I try to search by aproximation the query doesn't works:

"@\\{http\\://www.alfresco.org/model/content/1.0\\}name: "+ name+"~"
or
"@\\{http\\://www.alfresco.org/model/content/1.0\\}name:'+ name +"*"
I obtain a lot of results that doesn't match with the query. What's wrong here?

Thanks a lot peope.
5 REPLIES 5

jtorres
Champ in-the-making
Champ in-the-making
I've seen that it's a problem with names containing spaces, Lucene doesn't work correctly with them. If I try to search "SampleContent" it works fine, but if I try to find "Test Folder" it doesn't works.

Is there any problem with spaces in Lucene? :?:

Thanks people.

kevinr
Star Contributor
Star Contributor
If the search term contains spaces you can quote it:

@\{http\://www.alfresco.org/model/content/1.0\}name:'Test Folder"
Thanks,

Kevin

jtorres
Champ in-the-making
Champ in-the-making
Thanks Kevin  :wink:

bindiya
Champ in-the-making
Champ in-the-making
Hi

I use following query to search content for their TITLE as well as TEXT in the document. But this returns result only contents and files with the specified TITLE, it ignores TEXT search.
Is anything wrong with my query?

StringBuffer sb = new StringBuffer();
sb.append("TYPE:\"{").append(NamespaceService.CONTENT_MODEL_1_0_URI).append("}content\" ") ;
sb.append("+@").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:title:"test" TEXT:"test");

Query query = new Query(Constants.QUERY_LANG_LUCENE, sb.toString());

Thanks
Bindiya

cyrielleb
Champ in-the-making
Champ in-the-making
Hi Bindiya,

You can use the following query to search content for their NAME as well as TEXT in a document :


String docId = "99.xml";
String text = "textToSearch";
String queryString = "@cm\\:name:\"" + docId + "\" AND TEXT:\""+text+" \"";
Query query = new Query(Constants.QUERY_LANG_LUCENE, queryString); 

Regards,
CyrielleB