Hey Thomas,

That seems to work indeed :), but regretfully it has to be full text search, I 
don't know the property name beforehand.. 

Just to make sure I fully understand why it doesn't work with full text 
searching, do you think the % character is already parsed out when it is put in 
the index? 
Or is the % character inside the fulltext index.

Greets,
Roy
> On 12 Jan 2017, at 14:08, Thomas Mueller <[email protected]> wrote:
> 
> Hi,
> 
> If you know the property where this word can appear, you could use
> "like([property], '%\%\%myword\%\%%')". For "like", '%' is a wildcard
> (same as for SQL), so you must not escape the first and last character.
> But because you want to search for '%', you need to escape all other cases.
> 
> Regards,
> Thomas
> 
> 
> 
> 
> On 12/01/17 12:36, "Roy Teeuwen" <[email protected]> wrote:
> 
>> Hey Thomas,
>> 
>> Thanks for the info!
>> 
>> I am using Jackrabbit Oak. (version 1.2.17). The thing is that  I would
>> like to prefer to not find all the nodes that contain myword but not
>> %%myword%%, seeing as myword could for example be 'site', and this would
>> return too many results, I only want the results that really contain
>> '%%site%%', not just 'site'
>> 
>> I have tried the \ escape character, unfortunately both returning the
>> same result as without escape character
>> 
>>      /jcr:root/myfolder//*[jcr:contains(., '\%\%myword\%\%')]
>>      SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/myfolder]) and
>> CONTAINS(s.*, '\%\%myword\%\%')
>> 
>> Do you see any other option without having to use
>> /jcr:root/myfolder//*[jcr:contains(., 'myword')] and  iterate all the
>> results in java to check for %%myword%%?
>> 
>> Thanks!
>> Roy
>> 
>>> On 12 Jan 2017, at 11:52, Thomas Mueller <[email protected]> wrote:
>>> 
>>> Hi,
>>> 
>>> For jcr:contains, the escape character is '\'. Maybe the problem is that
>>> the fulltext index is not configured to index special characters such
>>> as %
>>> (it depends on the configuration; see "analyzed"). I would try this:
>>> 
>>>   /jcr:root/myfolder//*[jcr:contains(., 'myword')]
>>> 
>>> 
>>> There might be also a difference between Jackrabbit 2.x and Jackrabbit
>>> Oak. Which one (and which version) do you use?
>>> 
>>> Regards,
>>> Thomas
>>> 
>>> 
>>> 
>>> On 11/01/17 18:18, "Roy Teeuwen" <[email protected]> wrote:
>>> 
>>>> Hey all,
>>>> 
>>>> I am trying to do a query where the actual word I am looking for looks
>>>> like %%myword%%. I have tried the following in XPATH and JCR_SQL2, but
>>>> it
>>>> seems that the % sign is in both query languages a wildcard, meaning i
>>>> will find all the nodes containing myword instead of %%myword%%. How
>>>> can
>>>> I escape the % sign in either XPATH or JCR_SQL2?
>>>> 
>>>> JCR_SQL2:
>>>>    SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/myfolder]) and
>>>> CONTAINS(s.*, '%%myword%%')
>>>> 
>>>> XPATH:
>>>>    /jcr:root/myfolder//*[jcr:contains(., '%%myword%%')]
>>>> 
>>>> Thanks!
>>>> Roy
>>> 
>> 
> 

Reply via email to