Search attachments by filename

Hi guys. I need your help with Atlassian SDK for Confluence. Im developing custom plugin and I have to search attachments by filename, startsWith syntax, exactly like SQL query syntax (eg. filename like ‘lorem ipsum*’). Im using with new TextFieldQuery("filename", fileQuery, BooleanOperator.AND). Parameter fileQuery contains query from user, programatically appended with wildcard *. Problem is that search results are inconsistent and inaccurate. For example here are test queries for attachment with filename 09062013_WCO schemaPlatby.pdf. Attachment filename contains 3 words:

  • 09062013_WCO
  • schemaPlatby
  • pdf

Test queries:

  1. 09062013_WCO schemaPlatby - FOUND
  2. 09062013_WCO schemaPlatb - FOUND
  3. 09062013_WCO schemaPlat - NOT FOUND
  4. 09062013_WCO schemaPlat* - FOUND
  5. 09062013_WCO - FOUND
  6. 09062013_WCO* - NOT FOUND
  7. 09062013_WC - FOUND
  8. 09062013_WC* - NOT FOUND
  9. 09062013_W - NOT FOUND
  10. 09062013_W* - FOUND
  11. 09062013 - FOUND
  12. 09062013* - FOUND

As you can see in examples, wildcard sometimes helps but sometimes not. In few cases wildcard does not matter. The behaviour is very unpredictable and inconsitent. Please do you know where could be the problem? Am I doing something wrong?

Thanks for your time.