Tuesday, July 8, 2014

Structuring Content for Faceted / QueryBuilder Searches

Tip #1 - Use the correct data types and ensure values are saved correctly. For example, if you have a date that is being saved as a string. Everything may seem fine right now, but as soon as you want to use QueryBuilder to find the content, it won't return the results you expect.

Tip #2 - Never, ever use custom data types. Use mix-ins. You've been warned.

Tip #3 - Test your content to make sure it is searchable by using the Query Builder Debugger. http://localhost:4502/libs/cq/search/content/querydebug.html

Tip #4 - Don't over complicate your data structure. For example, don't nest a bunch of nt:unstructured nodes so it makes it impossible to search the content.

Tip #5 - When you search, you typically want to sort by jcr:score. If you're not receiving the results you want, then you need to tweak the rules in your query. For example, if you want to do this at runtime, you could add, "^2" to the end of a query to property the value of a result.

QueryBuilder Predicate Operations

Exists
1_property.operation=exists
1_property=submitted

Not Exists
1_property.operation=not
1_property=submitted

Like
1_property.operation=like
1_property.value=%Apples%
1_property=jcr:title

Equals
1_property.operation=equals
1_property=jcr:title
1_property.value=Apples

Unequals (Not equals)
1_property.operation=unequals
1_property=jcr:title
1_property.value=Apples

Date Ranges
1_daterange.property=@jcr:content/jcr:created
1_daterange.lowerBound=2015-02-22
1_daterange.upperBound=2015-01-01

Skip Node Iterator Count in QueryBuilder (Save significant amount time if you have a custom authorization provider for nodes, but you don't get a count)
p.guessTotal=true



No comments:

Post a Comment