cancel
Showing results for 
Search instead for 
Did you mean: 

Searching a file in repository

itsard
Champ in-the-making
Champ in-the-making
Hi,
Can u help me with this…
I need to search a document in Alfresco repository.
I pass the file name and need to get the reference to it.
Below is the code am using.
Query query1 =new Query(Constants.QUERY_LANG_LUCENE,"PATH:\"/app:company_home/cm:sample_folder/cm:"+ISO9075.encode(lStringFileName)+"\"");

Whether I use the ISO9075.encode or not it gives random result.Sometimes it finds the doc and sometime doesnt. There is some prob with the documents having "_,digits,spaces" in their names.
Can u let me know the code for searching a document in the repository.
Alfresco version : 3.0 community edition

Thanks.
21 REPLIES 21

openpj
Elite Collaborator
Elite Collaborator
In this way you are searching for a space or all the contents in a space, maybe you would like to execute this query:
Query query1 =new Query(Constants.QUERY_LANG_LUCENE,"PATH:\"/app:company_home/cm:sample_folder/*" AND @cm\\:name:"+ISO9075.encode(lStringFileName)+"\"");
Hope this helps.

itsard
Champ in-the-making
Champ in-the-making
Hi,
Thanks for your reply.
I tried your query, it gave me a compilation error.
Tried to get it working on node browser as below but dint find any record :
PATH:"/app:company_home/cm:sample_folder/*" AND @cm:\\name:hello.txt"
There is a hello.txt file in the webservice sample folder i.e. sample_folder and I am trying to search it to get the reference.
Can you kindly run your query in the node browser and chk if its working.
Kindly do let me know.
Thanks again.

luisg
Champ in-the-making
Champ in-the-making
try:

PATH:"/app:company_home/cm:sample_folder/*" AND @cm\:name:"hello.txt"

itsard
Champ in-the-making
Champ in-the-making
Hi,
How can i search a text in only some documents through webservice api.
My requirement is a content search that searches the input text only in some UUIDs or reference objects that I pass as input to the query.
Can someone help me with the query for it.

luisg
Champ in-the-making
Champ in-the-making
Ok…
You want to find a string inside a document identified by its reference? It's that what you want?
if so, suppose you want to find the string 'test' in a document with the reference 'ReferenceX' you should do:

ID:"ReferenceX" AND TEXT:"test"

Tried that in Alfresco Node Browser ans works!

Hope it helps

Luis

itsard
Champ in-the-making
Champ in-the-making
Thanks a lot for ur reply.
I will try this out. Instead of a single ID, I need to check it in more than one references.Whats the query for that?

I also had another question.
I am using the SOAP webservice api.
Can you kindly let me know is there a way to get the Version2Store node-uuid of my document when i check in the file.
My requirement is I need to save the version2Store node-uuid of the document when I check it in so that next time I can directly access it using the reference object from version2Store.

itsard
Champ in-the-making
Champ in-the-making
Hi,
I need to perform content search on documents inside a folder whose node-uuid I have.
I need to perform a hierarchical search, means searching the documents also inside all the children folders of the one whose node uuid i provide.

PARENT:"workspace://SpacesStore/cbb81351-4e7b-49cd-85c3-9dd423fdad2c"  TEXT:"bbb"
This code finds the documents but only in that particular folder and not in the children.
Can anyone help me out with this?
Thanks.

luisg
Champ in-the-making
Champ in-the-making
Hey…

You have the uuid of the folder you want, but for this you just need the path for the folder.
Suppose you have a folder 'test' inside Company Home and you need to search for all the documents that contain the String 'message'… to do this you need to perform the query:


PATH:"/app:company_home/cm:test//*" AND TEXT:"message"

I tried this with the following folder structure (all files have 'message' in its content):

Companhy Home
   file1
   file2
   file3
   subfolder1
      file4
      subfolder2
         file5

Hope it helps

Luis

itsard
Champ in-the-making
Champ in-the-making
Thanks for the reply.
But I dont wish to make the path…as I am integrating alfresco with my system…and the same logical folder would be created in my system also.
I map the alfresco folder uuid in my system against the system folder id.
What I wish is I just provide the folder uuid in the query and it does the content search for all the docs in the below hierarchy.
Is there a way to do this?
Thanks again for ur reply.