Search samples
Esta página aún no está disponible en tu idioma.
Basics
Section titled “Basics”Most methods use QueryParams here there’re some tips about how to use them.
| Variables | Type | Allow wildcards | Restrictions | Description |
|---|---|---|---|---|
| domain | long | No. | Available values: - QueryParams.DOCUMENT - QueryParams.FOLDER - QueryParams.MAIL - QueryParams.RECORD By default the value is set to QueryParams.DOCUMENT. For searching documents and folders use value: <br>(QueryParams.DOCUMENT | QueryParams.FOLDER) <br> |
Restrict the search to a node type. |
| author | String | No. | The value must be a valid userId. | Filter by creator user. |
| name | String | Yes. | Filter by node name. | |
| title | String | Yes. | Filter by title name. | |
| keywords | List |
Yes. | Filter by keywords. | |
| categories | List |
No. | Values should be categories UUID, not use path value. | Filter by categories. |
| content | Yes. | Filter by binary content. | ||
| mimeType | No. | The value should be a valid and registered MIME type. Only can be applied to documents node. |
Filter by document MIME type. | |
| language | No. | The value should be a valid language. Only can be applied to documents node. |
Filter by document language. | |
| folder | No. | When empty is used by default “/okm:root” node. The value should be a valid UUID, not use a path value. |
Filter by a folder. | |
| folderRecursive | Boolean | No. | It only makes sense to set this variable to true when the variable folder is not empty. | Enable filter recursively by a folder. |
| lastModifiedFrom | Calendar | No. | Filter by nodes created after a date. | |
| lastModifiedTo | Calendar | No. | Filter by nodes created 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 the field. |
| mailTo | Yes. | Only applies to mail nodes. | Filter by mail to the field. | |
| notes | Yes. | Filter by notes. | ||
| properties | Dictionary<String, String> | Yes on almost. | On metadata field values like “date” cannot be applied wildcards. The dictionary of the properties is composed of pairs: (‘metadata_field_name’,’metada_field_value”) For example: <br>Dictionary<String, String> properties = new Dictionary<String, String>();<br>properties.Add("okp:consulting.name", "name value")<br>Filtering by a range of dates: <br> DateTime date = DateTime.Now;// today<br> DateTime to = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond); <br> DateTime from = to.AddDays(-3);// three days before<br> Dictionary<String,String> properties = new Dictionary<String,String>();<br> properties.Add("okp:consulting.date", ISO8601.formatBasic(from)+","+ISO8601.formatBasic(to));<br>When filtering by a 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: <br><select label="Multiple" name="okp:consulting.multiple" type="multiple"><br> <option label="One" value="one"/><br> <option label="Two" value="two"/><br> <option label="Three" value="three" /><br></select><br>You should do: <br>properties.Add("okp:consulting.multiple", "one;two");<br>Where “one” and “two” are valid values and character “;” is used as a separator. |
Filter by metadata group values. |
Wildcard examples:
| Variable | Example | Description |
|---|---|---|
| name | test*.html | Any document that starts with the characters “test” and ends with characters “.html” |
| name | test?.html | Any document that starts with the characters “test” followed by a single character and ends with characters “.html” |
| name | ?test* | Any document where the first character doesn’t matter but is followed by the characters, “test”. |
Methods
Section titled “Methods”findByContent
Section titled “findByContent”Description:
| Method | Return values | Description |
|---|---|---|
| findByContent(String content) | List |
Returns a list of results filtered by the value of the content 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: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
Section titled “findByName”Description:
| Method | Return values | Description |
|---|---|---|
| findByName(String name) | List |
Returns a list of results filtered by the value of the name 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: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
Section titled “findByKeywords”Description:
| Method | Return values | Description |
|---|---|---|
| findByKeywords(List |
List |
Returns a list of results filtered by the values of the keywords 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: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()); } } }}Description:
| Method | Return values | Description |
|---|---|---|
| find(QueryParams queryParams, String propertiesPlugin) | List |
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:8080/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, null)) { System.Console.WriteLine(qr); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}findPaginated
Section titled “findPaginated”Description:
| Method | Return values | Description |
|---|---|---|
| findPaginated(QueryParams queryParams, int offset, int limit, String propertiesPlugin) | ResultSet | Returns a list of paginated 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:8080/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, null); 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
Section titled “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. |
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
Section titled “findMoreLikeThis”Description:
| Method | Return values | Description |
|---|---|---|
| findMoreLikeThis(String uuid, int max) | ResultSet | Returns a list of documents that are considered similar by the search engine. |
- The uuid is a document UUID.
- The max value is used to limit the number of results returned.
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
Section titled “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:
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
Section titled “getCategorizedDocuments”Description:
| Method | Return values | Description |
|---|---|---|
| getCategorizedDocuments(String categoryId) | List |
Retrieves a list of all documents related with a category. |
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()); } } }}saveSearch
Section titled “saveSearch”Description:
| Method | Return values | Description |
|---|---|---|
| saveSearch(QueryParams params) | Long | Saves search parameters. |
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 { QueryParams qParams = new QueryParams(); qParams.domain = QueryParams.DOCUMENT; qParams.name = "test*.html"; foreach (QueryResult qr in ws.find(qParams)) { System.Console.WriteLine(qr); } // Save the search to be used later qParams.queryName = "sample search"; ws.saveSearch(qParams); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}updateSearch
Section titled “updateSearch”Description:
| Method | Return values | Description |
|---|---|---|
| updateSearch(QueryParams params) | void | Updates a previously saved search parameters. |
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 (QueryParams qParams in ws.getAllSearchs()) { if (qParams.queryName.Equals("sample search")) { // Change some value. qParams.name = "admin*.html"; ws.updateSearch(qParams); } } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getSearch
Section titled “getSearch”Description:
| Method | Return values | Description |
|---|---|---|
| getSearch(int qpId) | QueryParams | Gets saved searches parameters. |
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 { int qpId = 1; // Some valid search id QueryParams qParams = ws.getSearch(qpId); System.Console.WriteLine(qParams); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getAllSearchs
Section titled “getAllSearchs”Description:
| Method | Return values | Description |
|---|---|---|
| getAllSearchs() | List |
Retrieves a list of all saved search parameters. |
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 (QueryParams qParams in ws.getAllSearchs()) { System.Console.WriteLine(qParams); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}deleteSearch
Section titled “deleteSearch”Description:
| Method | Return values | Description |
|---|---|---|
| deleteSearch(int qpId) | void | Deletes a saved search parameters. |
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, username, password); try { int qpId = 1; // Some valid search id ws.deleteSearch(qpId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}findByQueryPaginated
Section titled “findByQueryPaginated”Description:
| Method | Return values | Description |
|---|---|---|
| findByQueryPaginated(int offset, int limit, String query, String propertiesPlugin) | ResultSet | Returns a list of paginated results filtered by the values of the parameters. |
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.findByQueryPaginated(20, 10, "name:grial", null); 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()); } } }}