LIKE Operator doesn't search in between the string

0 votes

Hi,

We are trying to do a search using LIKE operator, but it only searches the string at the start and not anywhere in between. Below is the query:

Query query = QueryBuilder.build(Constants.MOVIE_TITLE, searchString, Operator.LIKE);

Following are the logs printed using App42Log.setDebug(true):

Request :: {"maxRecords":100,"searchString":"Potter","requestCode":"33","offset":0}
 Setting value :jsonQuery : [{"value":"Potter","operator":"$lk","key":"title"}]
 QueryString is ?jsonQuery=%5B%7B%22value%22%3A%22Potter%22%2C%22operator%22%3A%22%24lk%22%2C%22key%22%3A%22title%22%7D%5D&
 Setting Header value : signature : yZNwCzsH0ELXRvTg%2Frc41nE0EEY%3D
 Setting Header value : version : 1.0
 Setting Header value : SDKName : Java
 Setting Header value : timeStamp : 2016-03-08T20:28:18.205Z
 Setting Header value : apiKey : bdd80d43a10e63f9977032785de20f0f6cb7087e487e56e0c2d8f7ae086cbced
App42Exception : {"app42Fault":{"httpErrorCode":404,"appErrorCode":2608,"message":"Not Found","details":"No document in the collection 'MOVIES' exists for given query"}}
For Eg. if movie title is "Harry Potter", we get the results when searching with "Harry" but not with "Potter". Please let us know if anything is incorrect. It doesn't work on App42 HQ Management dashboard as well. We tried "%Potter%" as well, it doesn't work either.
 
Also, is there a way to do case-insensitive search?

 

related to an answer for: How to make a LIKE query.
asked Mar 8, 2016 in Java by jitesh.h.lalwani (20 points)

1 Answer

0 votes
Hi Jitesh,

 

Is it possible that you can share sample JSON which you have stored inside App42 Database. Also, please share code snippet which you have used. It will help us to provide better support to you.

 

P.S If possible then please share your App Name, DbName and Collection name at support@shephertz.com.

 

Regards,

Himanshu Sharma
answered Mar 9, 2016 by hs00105 (2,005 points)
Hi Himanshu,
Please see the json below:

{"trailer":"https://www.youtube.com/watch?v=mObK5XD8udk","editorChoice":"N","insertDate":"Sat Feb 06 2016 20:36:50 GMT+0530 (India Standard Time)","updateDate":"Sun Feb 07 2016 00:14:00 GMT+0530 (India Standard Time)","oscarWinner":"N","title":"Harry Potter and the Deathly Hallows-Part 2","username":"sawant.p@somaiya.edu","facts":["It is the 8th highest-grossing film of all time."],"background":"Adventure/Fantasy","poster":"http://cdn.shephertz.com/repository/files/bdd80d43a10e63f9977032785de20f0f6cb7087e487e56e0c2d8f7ae086cbced/a4510e12b1b94ce7850ff4d48dd8f591c84bfa73/Harry Potter and the Deathly Hallows-Part 2.jpg","synopsis":"Harry's quest of hunting the Horcruxes continues as Voldemort begins to tighten his control on the magical world. Voldemort's army is at the threshold of Hogwarts when Harry learns of a very disconcerting truth about him. Blood is shed, sacrifices are made, loyalties are revealed and every little effort counts in the last chapter of this epic saga.","writers":["Steve Kloves"],"docId":"56b610eae4b0339949655762","directors":["David Yates"],"producers":["David Heyman","David Barron","J.K. Rowling"]}


Below is the query used :
Query query = QueryBuilder.build(OnFridayConstants.MOVIE_TITLE, searchString, Operator.LIKE);
Any update on this?
Hi Jitesh,

I have tested the same at my end and its working fine. Please find below logs and let me know if you are missing anything:

 Setting value :jsonQuery : [{"value":"Potter","operator":"$lk","key":"title"}]
 QueryString is ?jsonQuery=%5B%7B%22value%22%3A%22Potter%22%2C%22operator%22%3A%22%24lk%22%2C%22key%22%3A%22title%22%7D%5D&
 Requested URL is https://api.shephertz.com/cloud/1.0/storage/findDocsByQuery/dbName/Test/collectionName/TwitterDM?jsonQuery=%5B%7B%22value%22%3A%22Potter%22%2C%22operator%22%3A%22%24lk%22%2C%22key%22%3A%22title%22%7D%5D&
 Setting Header value : signature : BqUEI8LtTVuNsUTIYM%2Fhw%2BaTwCI%3D
 Setting Header value : version : 1.0
 Setting Header value : SDKName : Java
 Setting Header value : timeStamp : 2016-03-13T05:16:49.639Z
 Setting Header value : apiKey : 85c9ff4dc443629504b60b41282af12eb43f62a49381277b8f5d212126a2a551
Response : {"app42":{"response":{"success":true,"storage":{"dbName":"Test","collectionName":"TwitterDM","recordCount":1,"jsonDoc":[{"_id":{"$oid":"56e4f709e4b0e89150c87a7a"},"trailer":"https://www.youtube.com/watch?v=mObK5XD8udk","editorChoice":"N","insertDate":"Sat Feb 06 2016 20:36:50 GMT+0530 (India Standard Time)","_$updatedAt":"2016-03-13T05:13:45.062Z","updateDate":"Sun Feb 07 2016 00:14:00 GMT+0530 (India Standard Time)","username":"sawant.p@somaiya.edu","title":"Harry Potter and the Deathly Hallows-Part 2","oscarWinner":"N","facts":["It is the 8th highest-grossing film of all time."],"background":"Adventure/Fantasy","poster":"http://cdn.shephertz.com/repository/files/bdd80d43a10e63f9977032785de20f0f6cb7087e487e56e0c2d8f7ae086cbced/a4510e12b1b94ce7850ff4d48dd8f591c84bfa73/Harry Potter and the Deathly Hallows-Part 2.jpg","synopsis":"Harry's quest of hunting the Horcruxes continues as Voldemort begins to tighten his control on the magical world. Voldemort's army is at the threshold of Hogwarts when Harry learns of a very disconcerting truth about him. Blood is shed, sacrifices are made, loyalties are revealed and every little effort counts in the last chapter of this epic saga.","writers":["Steve Kloves"],"_$createdAt":"2016-03-13T05:13:45.062Z","docId":"56b610eae4b0339949655762","directors":["David Yates"],"producers":["David Heyman","David Barron","J.K. Rowling"]}]}}}}
Test : TwitterDM : [56e4f709e4b0e89150c87a7a : {"trailer":"https://www.youtube.com/watch?v=mObK5XD8udk","editorChoice":"N","insertDate":"Sat Feb 06 2016 20:36:50 GMT+0530 (India Standard Time)","updateDate":"Sun Feb 07 2016 00:14:00 GMT+0530 (India Standard Time)","username":"sawant.p@somaiya.edu","title":"Harry Potter and the Deathly Hallows-Part 2","oscarWinner":"N","facts":["It is the 8th highest-grossing film of all time."],"background":"Adventure/Fantasy","poster":"http://cdn.shephertz.com/repository/files/bdd80d43a10e63f9977032785de20f0f6cb7087e487e56e0c2d8f7ae086cbced/a4510e12b1b94ce7850ff4d48dd8f591c84bfa73/Harry Potter and the Deathly Hallows-Part 2.jpg","synopsis":"Harry's quest of hunting the Horcruxes continues as Voldemort begins to tighten his control on the magical world. Voldemort's army is at the threshold of Hogwarts when Harry learns of a very disconcerting truth about him. Blood is shed, sacrifices are made, loyalties are revealed and every little effort counts in the last chapter of this epic saga.","writers":["Steve Kloves"],"docId":"56b610eae4b0339949655762","directors":["David Yates"],"producers":["David Heyman","David Barron","J.K. Rowling"]}]
{"app42":{"response":{"success":true,"storage":{"dbName":"Test","collectionName":"TwitterDM","recordCount":1,"jsonDoc":[{"_id":{"$oid":"56e4f709e4b0e89150c87a7a"},"trailer":"https://www.youtube.com/watch?v=mObK5XD8udk","editorChoice":"N","insertDate":"Sat Feb 06 2016 20:36:50 GMT+0530 (India Standard Time)","_$updatedAt":"2016-03-13T05:13:45.062Z","updateDate":"Sun Feb 07 2016 00:14:00 GMT+0530 (India Standard Time)","username":"sawant.p@somaiya.edu","title":"Harry Potter and the Deathly Hallows-Part 2","oscarWinner":"N","facts":["It is the 8th highest-grossing film of all time."],"background":"Adventure/Fantasy","poster":"http://cdn.shephertz.com/repository/files/bdd80d43a10e63f9977032785de20f0f6cb7087e487e56e0c2d8f7ae086cbced/a4510e12b1b94ce7850ff4d48dd8f591c84bfa73/Harry Potter and the Deathly Hallows-Part 2.jpg","synopsis":"Harry's quest of hunting the Horcruxes continues as Voldemort begins to tighten his control on the magical world. Voldemort's army is at the threshold of Hogwarts when Harry learns of a very disconcerting truth about him. Blood is shed, sacrifices are made, loyalties are revealed and every little effort counts in the last chapter of this epic saga.","writers":["Steve Kloves"],"_$createdAt":"2016-03-13T05:13:45.062Z","docId":"56b610eae4b0339949655762","directors":["David Yates"],"producers":["David Heyman","David Barron","J.K. Rowling"]}]}}}}

regards,
Himanshu Sharma
Hi,

It still doesn't work for us. And I cannot find anything wrong in the logs. Did you try this with sdk version 2.6?
Hi, It still doesn't work for us. Could you please provide more assistance here.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...