cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene Search based on filename

maqsood
Confirmed Champ
Confirmed Champ
Hi,

Can anyone help me out  ..
I am using web service to search a file in alfresco repository, here's the code:

RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();        
       
        // Create a query object, looking for all items with alfresco in the name of text
        Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/app:company_home/cm:" + searchText + "\"");
       
        // Execute the query
        final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
        QueryResult queryResult = repositoryService.query(STORE, query, false);
       
        // Display the results
        ResultSet resultSet = queryResult.getResultSet();
        ResultSetRow[] rows = resultSet.getRows();

I am passing file name from a custom search page without extension  as
searchText

for ex:
[just like search in alfresco DMS web client filtered on filename only]
Suppose i have two files File1.txt and file1.pdf and i want to search both the files just by passing file1 as my  searchText
I tried the same thing,  query returns nothing. And when I tried searching as File1.txt, query returns the exact file.
What could be the possible modification I should do with the above query to get my expected result.

Any suggestion appreciated

Thanks in advance
3 REPLIES 3

nvsreeram
Champ in-the-making
Champ in-the-making
Maqsood,

Try to search "File1", it should return both the entries - "File1.txt" and "File1.pdf".

sebp
Champ in-the-making
Champ in-the-making
If you want to search for name only:

+@cm\:name:*file1*
and if you additionally want to reduce the search to the direct descendants of company home:

+@cm\:name:*file1* +PATH:"/app:company_home/*"
This site http://wiki.alfresco.com/wiki/Search explains a lot.

maqsood
Confirmed Champ
Confirmed Champ
Thanks alot for your help guys.  Smiley Happy

Refering wiki resolves my problem. One more question I want to clarify may be Its there in wiki but i am not able to make out any solution.

Before displaying the result, How do I check user has enough permission to view the file(s)  :?:
I want to show the result iff user has permission to view the file otherwise some message.