Using special characters (greater than) in CMIS CONTAINS()

cancel
Showing results for 
Search instead for 
Did you mean: 
jecbm
Active Member

Using special characters (greater than) in CMIS CONTAINS()

Jump to solution

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?

 

1 Solution

Accepted Solutions
jecbm
Active Member

Re: Using special characters (greater than) in CMIS CONTAINS()

Jump to solution

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>\'')

 

View solution in original post

4 Replies
abhinavmishra14
Advanced

Re: Using special characters (greater than) in CMIS CONTAINS()

Jump to solution

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. 

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
jecbm
Active Member

Re: Using special characters (greater than) in CMIS CONTAINS()

Jump to solution

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.

jecbm
Active Member

Re: Using special characters (greater than) in CMIS CONTAINS()

Jump to solution

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>\'')

 

abhinavmishra14
Advanced

Re: Using special characters (greater than) in CMIS CONTAINS()

Jump to solution

So escaping does work. Glad you could figure out.

~Abhinav
(ACSCE, AWS SAA, Azure Admin)