Page 1 of 1

[solved] OKM find api returns random results

PostPosted:Mon Jan 26, 2015 4:16 pm
by Catscratch
Hi there,

I don't know if it's a bug or I'm doing something wrong. But whenever I query for documents through OKMSearch (DbSearchModule) with invalid properties I get random results instead of none.

I'm using latest community sources from sourceforge.

How to reproduce.

PropertyGroups.xml:
Code: Select all
<property-groups>
  <property-group label="test" name="test">
    <input label="Input Label 1" name="test.input" />
    <select label="Select Label 1" name="test.select" type="simple">
      <option label="Option A" value="optiona" />
      <option label="Option B" value="optionb" />
      <option label="Option C" value="optionc" />
      <option label="Option D" value="optiond" />
    </select>
    <input label="Input Label 2" name="test.inputagain" />
  </property-group>
<property-groups>
And now some documents in the system.

At least I try to find documents with invalid properties (just to check if a document is in the system containing a specific property).
Code: Select all
Map<String, String> properties = new HashMap<String, String>();
properties.put("roflmao", "awesome");

QueryParams p = new QueryParams();
p.setProperties(properties);
List<QueryResult> res = okm.find(p);
System.out.println(res.size());
Now I get 13 (!) documents. I don't know why I get this 13 documents, but I would assume to get no result, because there is no property "roflmao".

Thanks for hints.

Regards.

Re: OKM find API returns random results

PostPosted:Thu Jan 29, 2015 11:56 am
by jllort
First of all, you're using property groups in wrong way, the keys are wrong, you should use okg:XXXX at the begining for property group name definition and okp:XXX.YYYY for each property field.

You <property-group label="test" name="test"> is not right

Take a look here http://wiki.openkm.com/index.php/Proper ... definition and follow your definitions in same way.

Then try with something like:
Code: Select all
Map<String, String> properties = new HashMap<String, String>();
properties.put("okp:roflmao", "awesome");
Also try without setting the property ( could be a internal feature what cleans bad properties name and really you're doing something like full search without any restriction ).

Re: OKM find API returns random results

PostPosted:Mon Feb 02, 2015 1:01 pm
by Catscratch
jllort wrote: Also try without setting the property ( could be a internal feature what cleans bad properties name and really you're doing something like full search without any restriction ).
You're right. Without setting any parameter in QueryParams...13 results are returned. Strange!

Do you have any idea what magic is happening there?

Thanks!

Re: OKM find API returns random results

PostPosted:Tue Feb 03, 2015 7:11 pm
by jllort
I supect, but what is sure is that is not good idea filter by incorrect property group parameters, because is creating a lucene query what filter by values what does not exists -> that's why you get empty results.

Re: OKM find API returns random results

PostPosted:Wed Feb 04, 2015 7:59 am
by Catscratch
Ok thanks. So I'll try to verify the properties first before querying them. I think this should be a workaround.