No result when using ILIKE operator on the REST API
Hi, I'm trying to use the ILIKE operator with the REST API.
I have a Workspace named 'Shared' on my instance, so from the Nuxeo NXQL Console it is working with “SELECT * FROM Document WHERE dc:title LIKE / ILIKE 'Shared' “.
When I use GET (with Postman for example) on " http://NUXEO_SERVER/nuxeo/api/v1/search/lang/NXQL/execute?query=SELECT * FROM Document WHERE dc:title LIKE 'Shared' " it is working, but when I use the ILIKE operator on this request, I have no result.
Am I doing something wrong, or have I forgot something?
Hi, thanks for the response. I tried to reindex as you said but I have the same problem.
For more precision, I use Postman to make requests. Postman encodes itself the URL so there is no problem from this side. I have tested this comportment on a Nuxeo Docker container, and with the Nuxeo installer for Windows, both in the 10.10 version. I tried the request on a local instance and also from a Nuxeo behind a reverse-proxy.
- does not have any result.
But the request :
- has the right result.
I also tried to put the '%' in front and behind 'Shared' but the result is still the same.
So to resume with the Search API endpoint with a 'Shared' named workspace, I try:
LIKE 'Shared' -> ok
LIKE 'shared' -> PROBLEM
LIKE '%Shared%' -> ok
LIKE 'Shared%' -> ok
LIKE '%Shared' -> ok
ILIKE 'Shared' -> problem
ILIKE 'shared' -> problem …
Same thing with the 2nd localhost link, where you had results, I also had results.
So you are also using 10.10 version as well from what it sounds like. My next thing to try out would be to see if an earlier version of nuxeo works. Maybe try 9.10 and see if making a workspace named Shared there and try your queries again:
I haven't had any experience with using Postman, I've just run my instance locally and used a browser to place NXQL queries with links like:
I tried to recreate your setup with my own local instance of nuxeo (8.10). I created a workspace named “Shared”. I then used the API by typing in my browser:
" http://NUXEO_SERVER/nuxeo/api/v1/search/lang/NXQL/execute?query=SELECT * FROM Document WHERE dc:title ILIKE 'Shared' "
Obviously replace NUXEO_SERVER with what your server is, but this worked on my end and returned the document in the results. Keep in mind when placing in a browser, it will fill in spaces and special characters with encoded URL codes. So it will actually look like this:
" http://NUXEO_SERVER/nuxeo/api/v1/search/lang/NXQL/execute?query=SELECT%20*%20FROM%20Document%20WHERE%20dc:title%20ILIKE%20%27Shared%27 “
I would review the query you are using and check which operator you using, because it sounds like the reverse is happening of what's expected. If you were to use LIKE with 'shared', you would get no results (since the dc:title = “Shared”). If you use ILIKE, it should return.
Perhaps this is an issue tied with elasticsearch settings or the documents in the repository need to be re-indexed. Try re-indexing by going to the Admin section and going to Elasticsearch -> Admin (sub tab) and re-index the Shared workspace (I would use the 'Reindex Document and it's Children' where you just need to provide the Document ID). Then try the NXQL query again.
If you need more information, take a look here about endpoints https://doc.nuxeo.com/nxdoc/search-endpoints/
And about elasticsearch (and if you need to trace a search) https://doc.nuxeo.com/admindoc/60/elasticsearch-setup/#ElasticsearchSetup-ActivateTraces
I hope this helps a bit.