Strange behavior filter.addContain()

28 views
Skip to first unread message

arsdeep.singh

unread,
Aug 4, 2015, 11:01:29 AM8/4/15
to Hippo Community
Hi,

I am using hippo 7.9

I have a HstQuery with a Filter and at the end I execute the HstQuery in a HstQueryResult.

Problem 
filter.addContains("myproject:title", "model"); //this works correctly i get the result of 2 results what i expected 

filter.addContains("myproject:title", "model-test"); this does not work i get the result  of 0 results, this is strange i expected 3 results. 


How can i fix this?


Any suggestions or idea's? 


Thanks for your time and effort in advance. 


Regards,

Arsdeep


m.acharya

unread,
Aug 4, 2015, 11:10:07 AM8/4/15
to Hippo Community
Hi Arsdeep

Do you have any errors  reported in the logs? 

Best
Mahesh Acharya

Tobias Jeger

unread,
Aug 4, 2015, 11:28:15 AM8/4/15
to hippo-c...@googlegroups.com
Hi Arsdeep,

I suspect you might have to escape the hyphen character as described here [1].

HTH

Tobi



--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

arsdeep.singh

unread,
Aug 4, 2015, 1:25:42 PM8/4/15
to Hippo Community
Hi Tobi,

Thanks for your response. 

On the reference is the following written:
"Within the searchexp literal instances of single quote (“'”), double quote (“"”) and hyphen (“-”) must be escaped with a backslash (“\”). Backslash itself must therefore also be escaped, ending up as double backslash (“\\”)."

What i did:
String testReplace = "model-test".replaceAll("-", "\\-");

filter.addContains("myproject:title", testReplace ); 

This did not do the trick for me. Is the code incorrect? 

Any other suggestions? 

Regards,
Arsdeep

ps: I do not have any errors in my log.


Op dinsdag 4 augustus 2015 17:28:15 UTC+2 schreef t.jeger:

Tobias Jeger

unread,
Aug 5, 2015, 3:00:27 AM8/5/15
to hippo-c...@googlegroups.com
then I'm afraid I don't know. If you debug your code and retrieve the JCR query string just before you execute your query, does the result match your expectations? Try running the very same query in the Repository servlet and see if you get different results.

cheers

Tobi

arsdeep.singh

unread,
Aug 5, 2015, 4:37:00 AM8/5/15
to Hippo Community
Hi,

If i debug the query is what i expected. 
If i search in the  Repository servlet  with the xpath:
content/documents/myproject/test-folder//*[@atag:title='model-test' and @hippo:availability = 'live']


I get the correct 3 results

What else i did

final String test = SearchInputParsingUtils.parse("model-test", false);           

filter.addContains("myproject:title", test);


No results either. 

 



Op woensdag 5 augustus 2015 09:00:27 UTC+2 schreef t.jeger:

Tobias Jeger

unread,
Aug 5, 2015, 4:49:31 AM8/5/15
to hippo-c...@googlegroups.com
The latter I indeed expect to fail, see my comments on [1].

So in your repository servlet query, you don't escape the '-'?

Tobi


arsdeep.singh

unread,
Aug 5, 2015, 4:53:25 AM8/5/15
to Hippo Community
In my repository servlet query, I don't escape the '-'.

Regards,
Arsdeep

Op woensdag 5 augustus 2015 10:49:31 UTC+2 schreef t.jeger:
The latter I indeed expect to fail, see my comments on [1].

So in your repository servlet query, you don't escape the '-'?

Tobi


On Wed, Aug 5, 2015 at 10:37 AM, arsdeep.singh <arsdee...@incentro.com> wrote:
Hi,

If i debug the query is what i expected. 
If i search in the  Repository servlet  with the xpath:
content/documents/myproject/test-folder//*[@myproject:title='model-test' and @hippo:availability = 'live']

Tobias Jeger

unread,
Aug 5, 2015, 5:24:13 AM8/5/15
to hippo-c...@googlegroups.com
Hmm, then I'd expect you don't need to escape it in the filter either.

are the documents with the model-test title published? If not, that may be why you get no results.

arsdeep.singh

unread,
Aug 5, 2015, 5:29:38 AM8/5/15
to Hippo Community
In  Repository servlet  with the xpath:
content/documents/myproject/test-folder//*[@myproject:title='model-test' and @hippo:availability = 'live']
I get the correct 3 results. These are published documents 

Yes my documents are published.

I think I have to go for an workaround. 

Regards,
Arsdeep 


Op woensdag 5 augustus 2015 11:24:13 UTC+2 schreef t.jeger:

Minos Chatzidakis

unread,
Aug 5, 2015, 5:53:10 AM8/5/15
to Hippo Community
Hi,

I think the query you're testing with is not close to what is queried when using filter.addContains(..).
I would do the following:

1. Test with a query making use of jcr:contains, e.g. "//content/documents//*[jcr:contains(*, 'model-test')]"
2. Add a breakpoint in my code, just before the query.execute() call. There I would copy the query.toString() output and experiment with that in the repository servlet.

hth
Minos

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 745 Atlantic Ave, Eight Floor, MA 02111
Reply all
Reply to author
Forward
0 new messages