Search samples
Basics
Most methods use QueryParams here there're some clues about how using it.
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 value:
|
Restrict the search to a node types. |
author |
String |
No. |
Value must be a valid userId. |
Filter by creator user. |
name |
String |
Yes. |
|
Filter by node name. |
keywords |
List<String> |
Yes. |
|
Filter by keywords. |
categories |
List<String> |
No. |
Values should be categories UUID, not use path value. |
Filter by categories. |
content |
Yes. |
Filter by binary content. |
||
mimeType |
No. |
Value should be a valid and registered MIME type. Only can be applied to a documents node. |
Filter by document MIME type. | |
path |
No. |
When empty is used by default "/okm:root" node. |
Filter by a folder. |
|
lastModifiedFrom |
Calendar |
No. |
Filter by nodes created after a date. |
|
lastModifiedTo |
Calendar |
No. |
Filter by nodes creater 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 mail from field. |
mailTo |
Yes. |
Only applies to mail nodes. |
Filter by mail to field. |
|
properties |
Dictionary<String, String> |
Yes on almost. |
On metadata field values like "date" can not be applied wilcards. The dictionary of the properties is composed of pairs: ('metadata_field_name','metada_field_value") For example:
Filtering by range of dates:
When filtering by range of dates you must set both values ( from and to ), otherwise the filter will be ignored from OpenKM side. To filtering by a metadata field of type multiple like this:
You should do:
Where "one" and "two" are valid values and character ";" is used as separator. |
Filter by metadata group values.
|
The search operation is done only by AND logic. |
Wildcard examples:
Variable | Example | Description |
---|---|---|
name |
test*.html |
Any document that start with characters "test" and ends with characters ".html" |
name |
test?.html |
Any document that start with characters "test" followed by a single character and ends with characters ".html" |
name |
?test* |
Any the documents where the first character doesn't matter, but is followed by the characters, "test". |
Methods
findByContent
Description:
Method | Return values | Description |
---|---|---|
findByContent(String content) |
List<QueryResult> |
Returns a list of results filtered by the value of the content parameter. |
The method only searches among all documents, it does not takes in consideration any other kind of nodes. |
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, username, password);
try
{
foreach (QueryResult qr in ws.findByContent("test"))
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
findByName
Description:
Method | Return values | Description |
---|---|---|
findByName(String name) |
List<QueryResult> |
Returns a list of results filtered by the value of the name parameter. |
The method only searches among all documents, it does not takes in consideration any other kind of nodes. |
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, username, password);
try
{
foreach (QueryResult qr in ws.findByName("?test*"))
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
findByKeywords
Description:
Method | Return values | Description |
---|---|---|
findByKeywords(List<String> keywords) |
List<QueryResult> |
Returns a list of results filtered by the values of the keywords parameter. |
The method only searches among all documents, it does not takes in consideration any other kind of nodes. |
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, username, password);
try
{
List<string> keywords = new List<string>();
keywords.Add("test");
foreach (QueryResult qr in ws.findByKeywords(keywords))
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
find
Description:
Method | Return values | Description |
---|---|---|
find(QueryParams queryParams) |
List<QueryResult> |
Returns a list of results filtered by the values of the queryParams parameter. |
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, username, password);
try
{
QueryParams qParams = new QueryParams();
qParams.domain = QueryParams.DOCUMENT;
qParams.name = "test*.html";
foreach (QueryResult qr in ws.find(qParams))
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
findPaginated
Description:
Method | Return values | Description |
---|---|---|
findPaginated(QueryParams queryParams, int offset, int limit) |
ResultSet |
Returns a list of paginated results filtered by the values of the queryParams parameter. |
The parameter "limit" and "offset" allow you to retrieve just a portion of the results of a query.
For example if your query have 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:8180/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
try
{
QueryParams qParams = new QueryParams();
qParams.domain = QueryParams.DOCUMENT;
qParams.name = "test*.html";
ResultSet rs = ws.findPaginated(qParams, 20, 10);
System.Console.WriteLine("Total results:" + rs.total);
foreach (QueryResult qr in rs.results)
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
findSimpleQueryPaginated
Description:
Method | Return values | Description |
---|---|---|
findSimpleQueryPaginated(String statement, int offset, int limit) |
ResultSet |
Returns a list of paginated results filtered by the values of the statement 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.
The parameter "limit" and "offset" allow you to retrieve just a portion of the results of a query.
For example if your query have 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, username, password);
try
{
ResultSet rs = ws.findSimpleQueryPaginated(20, 10, "name:grial");
System.Console.WriteLine("Total results:" + rs.total);
foreach (QueryResult qr in rs.results)
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
findMoreLikeThis
Description:
Method | Return values | Description |
---|---|---|
findMoreLikeThis(String uuid, int max) |
ResultSet |
Returns a list of documents that are considered similar by search engine. |
The uuid is a document UUID. The max value is used to limit the number of results returned. The method can only be used with documents. |
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, username, password);
try
{
ResultSet rs = ws.findMoreLikeThis("c5cb1982-1a99-4741-8a07-a319b9ac3459", 100);
System.Console.WriteLine("Total results:" + rs.total);
foreach (QueryResult qr in rs.results)
{
System.Console.WriteLine(qr);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
getKeywordMap
Description:
Method | Return values | Description |
---|---|---|
getKeywordMap(String[] filter) |
Dictionary<String, Integer> |
Returns a map of keywords with its count value filtered by other keywords. |
Example:
The results filtering by "test" -> "one", "two", "three". The results filtering by "one" -> "test", "two". The results filtering by "two" -> "test", "one". The results filtering by "three" -> "test". The results filtering by "one" and "two" -> "test".
|
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, username, password);
try
{
// All keywords without filtering
System.Console.WriteLine("Without filtering");
Dictionary<String, int> keywords = ws.getKeywordMap(new String[]{"test", "test2"});
foreach (KeyValuePair<string,int> kvp in keywords)
{
System.Console.WriteLine(kvp.Key + " is used :" + kvp.Value);
}
// Keywords filtered
System.Console.WriteLine("Filtering");
keywords = ws.getKeywordMap(new String[]{"test"});
foreach (KeyValuePair<string,int> kvp in keywords)
{
System.Console.WriteLine(kvp.Key + " is used :" + kvp.Value);
}
}
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 with a category. |
The values of the categoryId parameter should be a category folder UUID or 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, username, password);
try
{
foreach (Document doc in ws.getCategorizedDocuments("/okm:categories/invoices"))
{
System.Console.WriteLine(doc);
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}