Page 1 of 1
Search by Folder
PostPosted:Mon Nov 10, 2008 6:47 pm
by Dena
Hi there,
How would one search in a particular folder and the children thereof making use of the findByContent,findByKeywords and findByName methods.
Best Regards
Dena
Re:Search by Folder
PostPosted:Tue Nov 11, 2008 12:02 pm
by pavila
Do you mean make search in a folder? This feature is not implemented actually.
Re:Search by Folder
PostPosted:Wed Nov 12, 2008 9:41 am
by Dena
Can I not use the findBystatement and use the XPath query to search in a particular folder. If possible can someone help me define the XPath query to do this.
Re:Search by Folder
PostPosted:Wed Nov 12, 2008 7:01 pm
by pavila
Yes, of course. I was thinking in the Web User Interface. With XPath you can make powerful search.
Re:Search by Folder
PostPosted:Wed Nov 12, 2008 8:29 pm
by Dena
Thanks, do you have an example of using XPath query that would do what I am looking for? I would really appreciate this.
Re:Search by Folder
PostPosted:Fri Nov 14, 2008 9:14 am
by pavila
In DirectSearchModule.java you can see how the XPath is constructed.
Re:Search by Folder
PostPosted:Sun Nov 16, 2008 7:11 pm
by Dena
Thanks I will have a look
Re:Search by Folder
PostPosted:Mon Nov 17, 2008 8:06 pm
by Dena
Hi there,
I have the following code which is supposed to search folder \"denzil\" which is a subfolder of the root folder (okm:root) for doc\'s that have keywords \"document\". However the search returns 0 records, when infact it should return 1 record. I would appreciate it if someone could assist me.
Best Regards
Dena
String username = \"denzil\";
String searchText = \"document\";
String search = \"/jcr:root/okm:root/\"+userName+\"//element(*,okm:document)[jcr:contains(@okm:keywords,\'\"+ searchText + \"\')] order by @jcr:score descending\";
Re:Search by Folder
PostPosted:Wed Nov 19, 2008 9:17 am
by pavila
I have make a test and works fine. Which version of OpenKM are you running?
Re:Search by Folder
PostPosted:Wed Nov 19, 2008 11:47 am
by Dena
Thanks I managed to sort out the problem, I added the following \"[1]\" to the query string. I read the JCR specification, they give great examples explaining the use of XPath for JCR.
String username = \"denzil\";
String searchText = \"document\";
String search = \"/jcr:root/okm:root/\"+userName+\"[1]//element(*,okm:document)[jcr:contains(@okm:keywords,\'\"+ searchText + \"\')] order by @jcrcore descending\";
Re:Search by Folder
PostPosted:Thu Nov 20, 2008 11:35 am
by pavila
I don\'t understand why you have to add this \"[1]\" ¿?