Understanding JCR Query search results
When you query the JCR repository using SQL2/Query Builder/XPath query, lucene handles the query in the backend. It orders the query based on a score it calculates. You can print the score using this code snippet
QueryManager qm = jcrSession.getWorkspace().getQueryManager();
String queryString = “SELECT * FROM [cq:PageContent] WHERE ” …..” ;
Query query = qm.createQuery(queryString, Query.JCR_SQL2);
// execute query
QueryResult result = query.execute();
// get column names
String columnNames = result.getColumnNames();
// get column rows
RowIterator rowIterator = result.getRows();
// get next row
Row row = rowIterator.nextRow();
// get all values of row
Value values = row.getValues();
//print the values. One of the values is jcr_score
The Score is calculated using pretty complex mathematical formula. You can read more about it at http://lucene.apache.org/core/3_6_2/api…ilarity.html
Some more explanation is provided at http://www.lucenetutorial.com/advanced-t…oring.html
Here are some main points:
- The length of document is number of terms not number of characters
- The relationship between frequency and length is not linear. It is sqrt(frequency/total terms in document)
- If your search has more than one term and one of the terms is a common term in the repository, then that common word gets less weightage. For e.g. if your content is for the company Polycom, then term like ‘conference might be a common term. So, when you search for ‘VOIP Conference’, then ‘conference’ would get lower weightage.
If you would like more help optimizing or managing your JCR Query, Contact Us Today.
Explore Additional Resources
Learn more on how to select the right CMS for your business and improve your customer’s Digital Experience.
Our Adobe Experience Cloud Consulting team specializes in helping you deliver a seamless, intelligent, and personalized customer experience.
About TA Digital
TA Digital is the only global boutique agency that delivers the “best of both worlds” to clients seeking to achieve organizational success through digital transformation. Unlike smaller, regional agencies that lack the ability to scale or large organizations that succumb to a quantity-over-quality approach, we offer resource diversity while also providing meticulous attention to the details that enable strategic success.
Over the past 20 years, TA Digital has positioned clients to achieve digital maturity by focusing on data, customer-centricity and exponential return on investment; by melding exceptional user experience and data-driven methodologies with artificial intelligence and machine learning, we enable digital transformations that intelligently build upon the strategies we set into motion. We are known as a global leader that assists marketing and technology executives in understanding the digital ecosystem while identifying cultural and operational gaps within their business – ultimately ushering organizations toward a more mature model and profitable digital landscape.
Recognized in 2013, 2014, 2015, 2019, and 2020 Inc. 5000 list as one of the most successful technology companies in the United States, TA Digital is pleased also to share high-level strategic partnerships with world class digital experience platform companies like Adobe, SAP and Salesforce and possess global partnerships with industry leaders such as Sitecore, Episerver, Elastic Path, BigCommerce, AWS, Azure and Coveo.