Search samples
Basics
Most methods use QueryParams. Here are some tips about how to use them.
| Variables | Type | Allow wildcards | Restrictions | Description |
|---|---|---|---|---|
|
domain |
long |
No. |
Available values:
By default, the value is set to QueryParams.DOCUMENT. For searching documents and folders, use the value: |
Restrict the search to a node type. |
|
author |
String |
No. |
The value must be a valid userId. |
Filter by creator. |
|
name |
String |
Yes. |
|
Filter by node name. |
|
title |
String |
Yes. |
Filter by title. | |
|
keywords |
List<String> |
Yes. |
|
Filter by keywords. |
|
categories |
List<String> |
No. |
Values should be category UUIDs; do not use path values. |
Filter by categories. |
|
content |
Yes. |
Filter by binary content. |
||
|
mimeType |
No. |
The value should be a valid and registered MIME type. Only applies to document nodes. |
Filter by document MIME type. | |
|
language |
No. |
The value should be a valid language. Only applies to document nodes. |
Filter by document language. |
|
|
folder |
No. |
When empty, the "/okm:root" node is used by default. The value should be a valid UUID; do not use a path value. |
Filter by a folder. |
|
|
folderRecursive |
Boolean |
No. |
It only makes sense to set this variable to true when the folder variable is not empty. |
Enable recursive filtering by a folder. |
|
lastModifiedFrom |
Calendar |
No. |
Filter by nodes modified after a date. |
|
|
lastModifiedTo |
Calendar |
No. |
Filter by nodes modified before a date. |
|
|
mailSubject |
String |
Yes. |
Only applies to mail nodes. |
Filter by mail subject field. |
|
mailFrom |
String |
Yes. |
Only applies to mail nodes. |
Filter by the mail From field. |
|
mailTo |
Yes. |
Only applies to mail nodes. |
Filter by the mail To field. |
|
|
notes |
Yes. |
Filter by notes. |
||
|
properties |
Dictionary<String, String> |
Yes, on almost all. |
Wildcards cannot be applied to metadata field values like "date". The dictionary of the properties is composed of pairs: ('metadata_field_name','metadata_field_value') For example:
Filtering by a range of dates:
When filtering by a range of dates, you must set both values (from and to); otherwise, the filter will be ignored by OpenKM. To filter by a metadata field of type multiple like this:
You should do:
Where "one" and "two" are valid values and the character ";" is used as a separator. |
Filter by metadata group values.
|
|
The search operation is performed using only AND logic. |
||||
Wildcard examples:
| Variable | Example | Description |
|---|---|---|
|
name |
test*.html |
Any document that starts with the characters "test" and ends with the characters ".html" |
|
name |
test?.html |
Any document that starts with the characters "test" followed by a single character and ends with the characters ".html" |
|
name |
?test* |
Any document where the first character doesn't matter but is followed by the characters "test". |
Suggested code sample
First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);
Then you should log in using the "login" method. You can access the "login" method from the webservice object "ws" as shown below:
ws.login(user, password);Once you are logged in with the webservices, the session is kept in the webservice object. Then you can use the other API methods.
At this point you can use all the search methods from the "search" class as shown below:
ws.search.find(qParams, null)Methods
find
Description:
| Method | Return values | Description |
|---|---|---|
|
find(QueryParams queryParams, String propertiesPlugin) |
List<QueryResult> |
Returns a list of results filtered by the values of the queryParams parameter. |
|
The parameter "propertiesPlugin" must be a canonical class name of the class which implements the NodeProperties interface. Retrieving entire objects (Document, Folder, Record, Mail) from REST can take a lot of time - the marshalling and unmarshalling process - while you are only interested in using a few object variables. If that's your case, you can use NodeProperties classes to retrieve only the object variables that you really need. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
QueryParams qParams = new QueryParams();
qParams.domain = QueryParams.DOCUMENT;
qParams.name = "test*.html";
foreach (QueryResult qr in ws.search.find(qParams, null))
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
find
Description:
| Method | Return values | Description |
|---|---|---|
|
find(QueryParams queryParams, String sortField, bool sortReverse, String propertiesPlugin) |
List<QueryResult> |
Returns a list of results filtered by the values of the queryParams parameter. |
|
The parameter "propertiesPlugin" must be a canonical class name of the class which implements the NodeProperties interface. Available sortField values:
Retrieving entire objects (Document, Folder, Record, Mail) from REST can take a lot of time - the marshalling and unmarshalling process - while you are only interested in using a few object variables. If it's your case, you can use NodeProperties classes to retrieve only the object variables that you really need. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
QueryParams _params = new QueryParams();
_params.domain = QueryParams.DOCUMENT + QueryParams.FOLDER;
_params.name = "test*";
foreach (QueryResult qr in ws.search.find(_params, SearchSortField.LAST_MODIFIED, true, null))
{
Console.WriteLine(qr.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findSimpleNodeBasePaginated
Description:
| Method | Return values | Description |
|---|---|---|
|
findSimpleNodeBasePaginated(QueryParams queryParams, int offset, int limit) |
SimpleNodeBaseResultSet |
Returns a list of SimpleNodeBase paginated results filtered by the values of the queryParams parameter. |
|
Because the results of the findSimpleNodeBasePaginated method are objects of type SimpleNodeBase, this method is about 60-70% faster than the other search methods (these metrics should be taken as approximate values because they depend on hardware and the specific scenario where the application is running). The other search methods return objects of type Node, which include full node data; the SimpleNodeBase object provides less data but in most cases should be enough. Especially when the limit is a higher value, you will appreciate the difference in performance. The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.
For example if your query has 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11-20, you should use these values:
|
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using com.openkm.sdk4csharp.impl;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
QueryParams qParams = new QueryParams();
qParams.domain = QueryParams.DOCUMENT;
qParams.name = "test*";
SimpleNodeBaseResultSet snbrs = ws.search.findSimpleNodeBasePaginated(qp, 0, 10);
System.Console.WriteLine("Total results:" + snbrs.total);
foreach (SimpleNodeBase snb in snbrs.results)
{
System.Console.WriteLine(snb.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findSimpleNodeBasePaginated
Description:
| Method | Return values | Description |
|---|---|---|
|
findSimpleNodeBasePaginated(QueryParams queryParams, String sortField, boolean sortReverse, int offset, int limit) |
SimpleNodeBaseResultSet |
Returns a list of SimpleNodeBase paginated results filtered by the values of the queryParams parameter. |
|
Because the results of the findSimpleNodeBasePaginated method are objects of type SimpleNodeBase, this method is about 60-70% faster than the other search methods (these metrics should be taken as approximate values because they depend on hardware and the specific scenario where the application is running). The other search methods return objects of type Node, which include full node data; the SimpleNodeBase object provides less data but in most cases should be enough. Especially when the limit is a higher value, you will appreciate the difference in performance. The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.
Available sortField values:
For example if your query has 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11-20, you should use these values:
|
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using com.openkm.sdk4csharp.impl;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
QueryParams qParams = new QueryParams();
qParams.domain = QueryParams.DOCUMENT;
qParams.name = "test*";
SimpleNodeBaseResultSet snbrs = ws.search.findSimpleNodeBasePaginated(params, SearchSortField.AUTHOR, true, 0, 10);
System.Console.WriteLine("Total results:" + snbrs.total);
foreach (SimpleNodeBase snb in snbrs.results)
{
System.Console.WriteLine(snb.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findSimpleNodeBasePaginated
Description:
| Method | Return values | Description |
|---|---|---|
|
findSimpleNodeBasePaginated(QueryParams queryParams, String sortField, bool sortReverse, int offset, int limit, String pluginName) |
SimpleNodeBaseResultSet |
Returns a list of SimpleNodeBase paginated results filtered by the values of the queryParams parameter. |
|
Because the results of the findSimpleNodeBasePaginated method are objects of type SimpleNodeBase, this method is about 60-70% faster than the other search methods (these metrics should be taken as approximate values because they depend on hardware and the specific scenario where the application is running). The other search methods return objects of type Node, which include full node data; the SimpleNodeBase object provides less data but in most cases should be enough. Especially when the limit is a higher value, you will appreciate the difference in performance. The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.
Available sortField values:
For example, if your query has 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11-20, you should use these values:
|
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using com.openkm.sdk4csharp.impl;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
QueryParams qp = new QueryParams();
qp.name = FOLDER_NAME1 + "*";
qp.domain = QueryParams.FOLDER;
SimpleNodeBaseResultSet result = ws.search.findSimpleNodeBasePaginated (qp, SearchSortField.AUTHOR, true, 0, 10, "com.openkm.plugin.search.TestNodeSearch");
Console.WriteLine("Total: " + result.total);
foreach (SimpleNodeBase nodeBase in result.results)
{
if (nodeBase != null)
{
Console.WriteLine(nodeBase.toString());
}
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}getCategorizedDocuments
Description:
| Method | Return values | Description |
|---|---|---|
|
getCategorizedDocuments(String categoryId) |
List<Document> |
Retrieves a list of all documents related to a category. |
| The values of the categoryId parameter should be a category folder UUID or a path. | ||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8180/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
foreach (Document doc in ws.search.getCategorizedDocuments("50b7a5b9-89d2-430e-bbc9-6a6e01662a71"))
{
System.Console.WriteLine(doc);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
saveSearch
Description:
| Method | Return values | Description |
|---|---|---|
|
saveSearch(QueryParams params) |
Long |
Saves search parameters. |
| The queryName variable of the params parameter must be initialized. | ||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
QueryParams qParams = new QueryParams();
qParams.domain = QueryParams.DOCUMENT;
qParams.name = "test*.html";
foreach (QueryResult qr in ws.search.find(qParams))
{
System.Console.WriteLine(qr);
}
// Save the search to be used later
qParams.queryName = "sample search";
ws.search.saveSearch(qParams);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
updateSearch
Description:
| Method | Return values | Description |
|---|---|---|
|
updateSearch(QueryParams params) |
void |
Updates previously saved search parameters. |
|
It can only be updated if it was created by the same user who is executing the method. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
foreach (QueryParams qParams in ws.search.getAllSearchs())
{
if (qParams.queryName.Equals("sample search"))
{
// Change some value.
qParams.name = "admin*.html";
ws.search.updateSearch(qParams);
}
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
getSearch
Description:
| Method | Return values | Description |
|---|---|---|
|
getSearch(int qpId) |
QueryParams |
Gets saved search parameters. |
|
It can only be retrieved if it was created by the same user who is executing the method. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
int qpId = 1; // Some valid search id
QueryParams qParams = ws.search.getSearch(qpId);
System.Console.WriteLine(qParams);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
getAllSearches
Description:
| Method | Return values | Description |
|---|---|---|
|
getAllSearches() |
List<QueryParams> |
Retrieves a list of all saved search parameters. |
|
It can only retrieve the list of saved searches created by the same user who is executing the method. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
foreach (QueryParams qParams in ws.search.getAllSearches())
{
System.Console.WriteLine(qParams.queryName);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
deleteSearch
Description:
| Method | Return values | Description |
|---|---|---|
|
deleteSearch(int qpId) |
void |
Deletes saved search parameters. |
|
It can only be deleted if it was created by the same user who is executing the method. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
int qpId = 1; // Some valid search id
ws.search.deleteSearch(qpId);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
getSearchConfig
Description:
| Method | Return values | Description |
|---|---|---|
|
getSearchConfig(String pluginName) |
NodeSearchConfig |
Returns a NodeSearchConfig object. |
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
NodeSearchConfig nodeSearchConfig = ws.search.getSearchConfig("com.openkm.plugin.search.TestNodeSearch");
Console.WriteLine(nodeSearchConfig.toString());
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}getSearchPlugins
Description:
| Method | Return values | Description |
|---|---|---|
|
getSearchPlugins() |
SearchPluginList |
Returns a SearchPluginList object. |
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
SearchPluginList pluginList = ws.search.getSearchPlugins();
foreach (SearchPlugin searchPlugin in pluginList.searchPlugins)
{
Console.WriteLine(searchPlugin.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findSimpleNodeBaseByQueryPaginated
Description:
| Method | Return values | Description |
|---|---|---|
|
findSimpleNodeBaseByQueryPaginated(String query, int offset, int limit) |
SimpleNodeBaseResultSet |
Returns a list of paginated results filtered by the values of the query parameter. |
|
The syntax to use in the statement parameter is the pair 'field:value'. For example:
More information about Lucene syntax at Lucene query syntax. The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.
For example if your query has 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11-20, you should use these values:
|
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
SimpleNodeBaseResultSet snbr = ws.search.findSimpleNodeBaseByQueryPaginated("text:grial AND name:t*.pdF", 0, 10);
foreach (SimpleNodeBase nodeBase in snbr.results)
{
if(nodeBase != null)
{
System.Console.WriteLine(nodeBase.toString());
}
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findSimpleNodeBaseByQueryPaginated
Description:
| Method | Return values | Description |
|---|---|---|
|
findSimpleNodeBaseByQueryPaginated(String query, String sortField, bool sortReverse, int offset, int limit) |
SimpleNodeBaseResultSet |
Returns a list of paginated results filtered by the values of the query parameter. |
|
The syntax to use in the statement parameter is the pair 'field:value'. For example:
More information about lucene sintaxis at Lucene query syntax. Available sortField values:
The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.
For example if your query has 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11-20, you should use these values:
|
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
SimpleNodeBaseResultSet snbr= ws.search.findSimpleNodeBaseByQueryPaginated("text:grial AND name:t*.pdF", SearchSortField.NAME, true, 0, 10);
foreach (SimpleNodeBase nodeBase in snbr.results)
{
if(nodeBase != null)
{
System.Console.WriteLine(nodeBase.toString());
}
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findByQuery
Description:
| Method | Return values | Description |
|---|---|---|
|
findByQuery(String query, String propertiesPlugin) |
List<QueryResult> |
Returns a list of results filtered by the values of the queryParams parameter. |
|
The parameter "propertiesPlugin" must be a canonical class name of the class which implements the NodeProperties interface. Retrieving entire Objects ( Document, Folder, Record, Mail ) from REST can take a lot of time - marshaling and unmarshalling process - while you are only interesting on using only a few Objects variables. If it's your case you can use NodeProperties classes for retrieving the Object variables what you really need. The syntax to use in the statement parameter is the pair 'field:value'. For example:
More information about lucene sintaxis at Lucene query syntax. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
foreach (QueryResult qr in ws.search.findByQuery("keyword:test AND name:t*.pdf", null))
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findByQuery
Description:
| Method | Return values | Description |
|---|---|---|
|
findByQuery(String query, String sortField, bool sortReverse, String propertiesPlugin) |
List<QueryResult> |
Returns a list of results filtered by the query parameter. |
|
The syntax to use in the statement parameter is the pair 'field:value'. For example:
More information about Lucene syntax is available at Lucene query syntax. Available sortField values:
The parameter "propertiesPlugin" must be the canonical class name of the class which implements the NodeProperties interface. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
foreach (QueryResult qr in ws.search.findByQuery("keyword: test", SearchSortField.NAME, true, null))
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findAllDefaultByNodeClass
Description:
| Method | Return values | Description |
|---|---|---|
|
findAllDefaultByNodeClass(long ncId) |
List<QueryParams> |
Retrieves a list of saved searches for a NodeClass. |
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
long ncId = 1;
List<QueryParams> queryParams = ws.search.findAllDefaultByNodeClass(ncId);
foreach (QueryParams qParams in queryParams)
{
System.Console.WriteLine(qParams.queryName);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findWithMetadata
Description:
| Method | Return values | Description |
|---|---|---|
|
findWithMetadata(QueryParams _params, String propertiesPlugin, List<String> groups) |
List<QueryResult> |
Returns a list of results with metadata values filtered by the queryParams parameter. |
|
Retrieving entire objects (Document, Folder, Record, Mail) from REST can take a lot of time ? the marshalling and unmarshalling process ? while you are only interested in using a few object variables. If that's your case, you can use NodeProperties classes to retrieve the object variables that you really need. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
// QueryParams
QueryParams qp = new QueryParams();
qp.folderRecursive = true;
qp.domain = QueryParams.DOCUMENT | QueryParams.FOLDER | QueryParams.RECORD | QueryParams.MAIL;
qp.name = "test*";
// Properties
Dictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("okp:consulting.name", "test");
qp.properties = properties;
// Groups
List<string> groups = new List<string>();
groups.Add("okg:consulting");
List<QueryResult> queryResults = ws.search.findWithMetadata(qp, null, groups);
foreach (QueryResult qResult in queryResults)
{
System.Console.WriteLine(qResult.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findWithMetadata
Description:
| Method | Return values | Description |
|---|---|---|
|
findWithMetadata(QueryParams queryParams, String sortField, bool sortReverse, String propertiesPlugin, List<String> groups) |
List<QueryResult> |
Returns a list of results with metadata values filtered by the queryParams parameter. |
Available sortField values:
Retrieving entire objects (Document, Folder, Record, Mail) from REST can take a lot of time ? the marshalling and unmarshalling process ? while you are only interested in using a few object variables. If that's your case, you can use NodeProperties classes to retrieve the object variables that you really need. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
// QueryParams
QueryParams qp = new QueryParams();
qp.folderRecursive = true;
qp.domain = QueryParams.DOCUMENT | QueryParams.FOLDER | QueryParams.RECORD | QueryParams.MAIL;
qp.name = "test*";
// Properties
Dictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("okp:consulting.name", "test");
qp.properties = properties;
// Groups
List<string> groups = new List<string>();
groups.Add("okg:consulting");
List<QueryResult> queryResults = ws.search.findWithMetadata(qp, SearchSortField.NAME, true, null, groups);
foreach (QueryResult qr in queryResults)
{
Console.WriteLine(qr.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findWithMetadataPaginated
Description:
| Method | Return values | Description |
|---|---|---|
|
findWithMetadataPaginated(QueryParams queryParams, int offset, int limit, String propertiesPlugin, List<String> groups) |
ResultSet |
Returns a list of paginated results with metadata values filtered by the queryParams parameter. |
|
The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.
For example, if your query has 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11 to 20, you should use these values:
Retrieving entire objects (Document, Folder, Record, Mail) from REST can take a lot of time ? the marshalling and unmarshalling process ? while you are only interested in using a few object variables. If that's your case, you can use NodeProperties classes to retrieve the object variables that you really need. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
// QueryParams
QueryParams qp = new QueryParams();
qp.domain = QueryParams.DOCUMENT | QueryParams.FOLDER | QueryParams.RECORD | QueryParams.MAIL;
qp.name = "test*";
// Properties
Dictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("okp:consulting.name", "test");
qp.properties = properties;
// Groups
List<string> groups = new List<string>();
groups.Add("okg:consulting");
ResultSet resulSet = ws.search.findWithMetadataPaginated(qp, 0, 10, null, groups);
System.Console.WriteLine("Total results: " + rs.total.ToString());
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}findWithMetadataPaginated
Description:
| Method | Return values | Description |
|---|---|---|
|
findWithMetadataPaginated(QueryParams queryParams, String sortField, bool sortReverse, int offset, int limit, String propertiesPlugin, List<String> groups) |
ResultSet |
Returns a list of paginated results with metadata values filtered by the queryParams parameter. |
|
The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.
The parameter "propertiesPlugin" must be the canonical class name of the class which implements the NodeProperties interface. The parameter "groups" must be valid metadata group names. Available sortField values:
For example, if your query has 1000 results, but you only want to return the first 10, you should use these values:
Now suppose you want to show the results from 11 to 20, you should use these values:
Retrieving entire objects (Document, Folder, Record, Mail) from REST can take a lot of time ? the marshalling and unmarshalling process ? while you are only interested in using a few object variables. If that's your case, you can use NodeProperties classes to retrieve the object variables that you really need. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
// QueryParams
QueryParams qp = new QueryParams();
qp.domain = QueryParams.DOCUMENT | QueryParams.FOLDER | QueryParams.RECORD | QueryParams.MAIL;
qp.name = "test*";
// Properties
Dictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("okp:consulting.name", "test");
qp.properties = properties;
// Groups
List<string> groups = new List<string>();
groups.Add("okg:consulting");
ResultSet rs = ws.search.findWithMetadataPaginated(qp, SearchSortField.AUTHOR, true, 0, 10, null, groups);
Console.WriteLine("Total results: " + rs.total.ToString());
foreach (QueryResult qr in rs.results)
{
Console.WriteLine(qr.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}getMimeTypes
Description:
| Method | Return values | Description |
|---|---|---|
|
getMimeTypes() |
List<MimeType> |
Retrieves a list of MIME types. |
|
Only the list of MIME types that may be used in the search will be retrieved. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
foreach (MimeType mimeType in ws.search.getMimeTypes())
{
System.Console.WriteLine(mimeType.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}csvExport
Description:
| Method | Return values | Description |
|---|---|---|
|
csvExport(String lang, QueryParams queryParams, bool compact) |
InputStream |
Exports a list of results as CSV, filtered by the values of the queryParams parameter. |
|
The parameter lang must be ISO 639-1 compliant. More information at: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
QueryParams _params = new QueryParams();
_params.domain = QueryParams.DOCUMENT + QueryParams.FOLDER;
_params.name = "test*";
Stream stream = ws.search.csvExport("es-ES", _params, false);
FileStream destFile = new FileStream("C:\\Testing\\export.csv", FileMode.OpenOrCreate);
stream.CopyTo(destFile);
destFile.Dispose();
stream.Dispose();
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}