• Search in document content with findByStatement

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #5218  by Linsche
 
Hello

I wonder how I have to use XPath to search within the content of documents. It workes pretty well with keywords and name but with content it always failes
Code: Select all
$result = $searchRequest->findByStatement($token, '/jcr:root/okm:root/DAI/Marken//element(*,okm:document)[jcr:contains(@okm:content,\'Ajax\')]order by @jcrcore descending', 'xpath'); //doesn't work

$result = $searchRequest->findByStatement($token, '/jcr:root/okm:root/DAI/Marken//element(*,okm:document)[jcr:contains(@okm:name,\'Ajax\')]order by @jcrcore descending', 'xpath'); //works

$result = $searchRequest->findByStatement($token, '/jcr:root/okm:root/DAI/Marken//element(*,okm:document)[jcr:contains(@okm:keywords,\'Ajax\')]order by @jcrcore descending', 'xpath'); //works

$result = $searchRequest->findByStatement($token, '/jcr:root/okm:root/DAI/Marken//element(*,okm:document)[jcr:contains(@okm:name,\'Ajax\') or jcr:contains(@okm:keywords,\'something\') ]order by @jcrcore descending', 'xpath'); //works
Thank you
 #8494  by Linsche
 
Hello,

thank you for the code but it is not working with the content. Keywords and name is not a problem but content doesn't work. I tried to put everything into one find - statement. This is also not working at all.
I have to fill the params. I think name, content, keywords and path are clear but i also have to fill domain, id, properties, dashboard. What ware they for ? This is what I filled :
Code: Select all
<?php
//some code

$params['dashboard'] = false;
$params['domain'] ='0;
$params['id'] = '';
$params['properties'] = array();
$params['name'] = 'myfilename';
$params['content'] = 'mycontent';
$params['keywords'] = 'mykeyword';
$params['operator'] = 'or';
$params['path'] = '/okm:root/path/to/folder;

$result = $searchRequest->find($token, $params);

//a lot of other code
?>
One time I tried some random id's and domains. There wars a result but only two files and a lot of empty folders. Do I have to specify that I only want so get documents as result?

Thank you!

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.