03-08-2022 07:59 AM
Hello, I need to query SOLR data using CMIS. I need to look at a combination of node properties and the content. The content of the nodes are XML data and I need to find key/value pairs of certain values.
With AFTS I can succesfully search in content like:
content:"<myTag>hello</myTag>"
In CMIS, you can search in content in the same way using CONTAINS().
So I'm trying to do something like:
SELECT * FROM si:myNodeType WHERE cm:name LIKE 'Some name' AND CONTAINS('<myTag>hello</myTag>')
This fails as it seems like the parser is not able to interpret the CONTAINS value literally:
Caused by: NoViableAltException(61@[445:1: ftsTest : ( ( ftsFieldGroupProximity )=> ftsFieldGroupProximity -> ^( PROXIMITY ftsFieldGroupProximity ) | ( ftsRange )=> ftsRange -> ^( RANGE ftsRange ) | ( ftsFieldGroup )=> ftsFieldGroup -> ftsFieldGroup | ( ftsTermOrPhrase )=> ftsTermOrPhrase | ( ftsExactTermOrPhrase )=> ftsExactTermOrPhrase | ( ftsTokenisedTermOrPhrase )=> ftsTokenisedTermOrPhrase | LPAREN ftsDisjunction RPAREN -> ftsDisjunction | template -> template );]) sirene-ass_1 | at org.alfresco.repo.search.impl.parsers.FTSParser$DFA17.specialStateTransition(FTSParser.java:17490) sirene-ass_1 | at org.antlr.runtime.DFA.predict(DFA.java:80) sirene-ass_1 | at org.alfresco.repo.search.impl.parsers.FTSParser.ftsTest(FTSParser.java:2691)
If I leave out the tags and just search for 'hello' for instance, content search works fine. How can I force the parser to understand that I want to search for this exact string?
03-11-2022 09:10 AM
It appears that I've figured it out. You have to escape the FTS statement as a whole, i.e :
SELECT * FROM si:myNodeType WHERE cm:name LIKE 'Some name' AND CONTAINS('\'<myTag>hello</myTag>\'')
03-08-2022 05:01 PM
May be try escaping the angle brackets, at least basic escaping should work (\< and \> should convert to < and >😞
SELECT * FROM si:myNodeType WHERE cm:name LIKE 'Some name' AND CONTAINS('\<myTag\>hello\</myTag\>')
According to this special characters are not allowed in the string value. I am not sure if it is still the case.
03-10-2022 08:23 AM
Escaping does not work. Interestingly enough, there is no error if I use multiple backslashes, as in CONTAINS('abc\\<') but no results are found either. I wonder what query is generated in that case.
The linked topic seems to refer to the behavior of the CMISParser class, whereas the CONTAINS() FTS value is parsed by CMISFTSQueryParser, so I wouldn't assume they are the same.
I have become aware that we are running version 1.2 of the search services. I wonder if more recent versions have solved the issue.
03-11-2022 09:10 AM
It appears that I've figured it out. You have to escape the FTS statement as a whole, i.e :
SELECT * FROM si:myNodeType WHERE cm:name LIKE 'Some name' AND CONTAINS('\'<myTag>hello</myTag>\'')
03-12-2022 02:35 PM
So escaping does work. Glad you could figure out.
Explore our Alfresco products with the links below. Use labels to filter content by product module.