Post

2 followers Follow
0
Avatar

DatabaseService Query returning unexpected results

I seem to be running into an issue with the DatabaseService pluginutilities returning unexpected results.  I am working on a plugin that takes an import from a CSV file containing a list of DNA molecule names within the local database and performs an action on those documents.  The action works fine in all cases but the DatabaseService does not always return the correct AnnottatedPluginDocument.

So if the CSV contains the following molecule names:

1.   HIS-TMV-XYZ1(1-159)-abc

2.   HIS-TMV-XYZ1(1-159)-cde

3.   HIS-TMV-XYZ1(1-159)-fgh

4.   HIS-TMV-XYZ1(1-159)-bhi

And molName = the first molecule name in the list.

and my query is:

Query[] searchValues1 = new Query[] {Query.Factory.createFieldQuery(DocumentField.ALL, Condition.CONTAINS, molName)

DatabaseService service = (DatabaseService)PluginUtilities.getGeneiousService("LocalDocuments");

List<AnnotatedPluginDocument> documents1;

documents1 = service.retrieve(totalQuery,listening);

 

documents1 List returns the following hits:

2.   HIS-TMV-XYZ1(1-159)-cde

3.   HIS-TMV-XYZ1(1-159)-fgh

4.   HIS-TMV-XYZ1(1-159)-bhi

If I change molName to the second molecule, documents1 List contains:

1.   HIS-TMV-XYZ1(1-159)-abc

3.   HIS-TMV-XYZ1(1-159)-fgh

4.   HIS-TMV-XYZ1(1-159)-bhi

 

There does seem to be an association with occurring based on the length of the molecule name.  Roughly names that are less than 35 characters give the expected results while longer names give the incorrect results.  If I try trimming the molecule names down I will occasionally get thrown an error depending on if the last trimmed character is a special character.

 

Any ideas would be greatly appreciated.

 

Brian

 

 

Brian Carpenter

Please sign in to leave a comment.

2 comments

0
Avatar

Problem Solved.

It appears that how the molName is handled within the Query was causing the problem.  The molecule name needs to be within double quotes to be handled correctly otherwise the Lucene queryParser has issues.

So 

Query[] searchValues1 = new Query[] {Query.Factory.createFieldQuery(DocumentField.ALL, Condition.CONTAINS, "\"" + molName + "\"")

Brian Carpenter 0 votes
Comment actions Permalink
0
Avatar

Hi Brian,

Great to hear you found and solved the problem :)

Matthew Cheung 0 votes
Comment actions Permalink