Page 1 of 1

Metadata properties ignored when using find method of SDK

PostPosted:Wed Jul 10, 2019 3:14 pm
by zaans2
When using the find method of the .NET SDK 1.2.2 (And 1.2.3 Alpha I got provided in another thread) it looks like the metadata properties I select are ignored.
Code: Select all
	Dim properties = New Dictionary(Of String, String)
	properties.Add("okp:foo", "bar")
	
	Dim searchTerm = "bar"
        Dim queryParams = New QueryParams With {
                .properties = properties,
                .domain = bean.QueryParams.DOCUMENT,
                .name = searchTerm
                }

        Try
            result = ws.find(queryParams)
        Catch exc As System.Exception
		Console.writeLine(exc.ToString())
        End Try
If I use the above code I get all results with "bar" in the name, even if a document doesn't have "bar" as the value of the property "okp:foo". I expect to only get the documents with "bar" in the name AND "bar" as value of the property "okp:foo"

Looking at the API description (https://docs.openkm.com/kcenter/view/ok ... pertyValue) I am doing it right but it doesn't work as expected. Am I doing something wrong or is what I am expecting to happen not correct?

Re: Metadata properties ignored when using find method of SDK

PostPosted:Fri Jul 12, 2019 12:47 pm
by zaans2
I don't know where it exactly should happen but I have found out what is happening.

The dictionary that is set as a QueryParam gets converted into a `List<string>` in the class `BeanHelper` in the method `dictionaryToList` (line 187-196). When the URI is built this list is never converted to a URL encoded string. The instance itself gets URL encoded and put into the string.

Re: Metadata properties ignored when using find method of SDK

PostPosted:Fri Jul 19, 2019 8:36 pm
by pherrera
Hi,
Thanks for the observation, I was not filtering through the properties.
Try this new compilation of sdk:
(69.08 KiB) Downloaded 197 times
[/b]
According to your metadata example, your query should look like this:
Code: Select all
            Dim properties = New Dictionary(Of String, String)
            properties.Add("okp:foobar.foo", "foo.intern")

            Dim searchName = "AnyFileName*"
            Dim queryParams = New QueryParams With {
                .domain = bean.QueryParams.DOCUMENT,
                .name = searchName,
                .properties = properties
                }

            Dim result = New List(Of QueryResult)
            result = ws.find(queryParams)
where the "name = searchName" will use it if you want to search also by the name of the file or just remove it.
This is not correct: properties.Add ("okp:foobar.foo", "bar")
according to your metadata definition the name is "okp:foobar.foo" and the value is "foo.intern" then -> properties.Add("okp:foobar.foo", "foo.intern")
Code: Select all
<select label="Foo" name="okp:foobar.foo" type="simple" >
            <option label="FooInternal" value="foo.intern"/>
            <option label="FooExternal" value="foo.extern"/>
        </select>
Please try it, I await your answer.
Regards.