<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> 
        <base href="https://hibernate.atlassian.net"> 
        <title>Message Title</title> 
    </head> 
    <body class="jira" style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429"> 
        <table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0" bgcolor="#f5f5f5"> 
            <!-- header here --> 
            <tbody>
                <tr> 
                    <td id="header-pattern-container" style="padding: 0; border-collapse: collapse; padding: 10px 20px"> 
                        <table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                            <tbody>
                                <tr> 
                                    <td id="header-avatar-image-container" valign="top" style="padding: 0; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px" width="32"> <img id="header-avatar-image" class="image_fix" src="cid:jira-generated-image-avatar-297f0a07-d4fd-4db3-bd30-34d4e58a231c" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top"> </td> 
                                    <td id="header-text-container" valign="middle" style="padding: 0; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="fenrhil" id="email_fenrhil" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=fenrhil" style="color:#6c797f;; color: #3b73af; text-decoration: none">Yoann Rodière</a> <strong>commented</strong> on <a href="https://hibernate.atlassian.net/browse/HSEARCH-1872" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-d111eb07-a47d-46b3-859f-6bfed49ab865" height="16" width="16" border="0" align="absmiddle" alt="New Feature"> HSEARCH-1872</a> </td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
                <tr> 
                    <td id="email-content-container" style="padding: 0; border-collapse: collapse; padding: 0 20px"> 
                        <table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; border-spacing: 0; border-collapse: separate"> 
                            <tbody>
                                <tr> 
                                    <!-- there needs to be content in the cell for it to render in some clients --> 
                                    <td class="email-content-rounded-top mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 15px; background-color: #ffffff; border-left: 1px solid #cccccc; border-top: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly" height="10" bgcolor="#ffffff">&nbsp;</td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff"> 
                                        <table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                            <tbody>
                                                <tr> 
                                                    <td style="vertical-align: top;; padding: 0; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HSEARCH-1872" style="color: #3b73af; text-decoration: none">Re: Create a proper API for sorting definitions</a> </span> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <tr> 
                                    <td id="text-paragraph-pattern-top" class="email-content-main mobile-expand  comment-top-pattern" style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; border-bottom: none; padding-bottom: 0" bgcolor="#ffffff"> 
                                        <table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px"> 
                                            <tbody>
                                                <tr> 
                                                    <td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0; border-collapse: collapse; padding: 0 0 10px"> 
                                                        <blockquote style="margin: 10px 0 0; margin-top: 0; border-left: 1px solid #cccccc; color: #707070; margin-left: 19px; padding: 10px 20px">
                                                            <p style="margin: 10px 0 0; margin-top: 0">Where is this API going?<br> Our ultimate goal is to be more independent of Lucene internal API. Currently, most of our machinery is based on Lucene API (we build our index with Lucene Documents for instance) and this has to change.<br> It's a Search 6 thing though.</p>
                                                        </blockquote> <p style="margin: 10px 0 0">Ok. So this API is bound to disappear in its current form.</p> 
                                                        <blockquote style="margin: 10px 0 0; border-left: 1px solid #cccccc; color: #707070; margin-left: 19px; padding: 10px 20px">
                                                            <p style="margin: 10px 0 0; margin-top: 0">Is this API going to support native sorts?<br> Native sorts are important. The fact is that Elasticsearch brings a lot of power to the user and it is really important to allow the user to use this power.</p>
                                                        </blockquote> <p style="margin: 10px 0 0">I completely agree with that. I was just saying that maybe we should try to provide a way to chain DSL-built sorts with native sorts (through another API, provided only by the ES module) instead of adding backend-dependent methods to the DSL. <br> But if the API is to be rebuilt from the ground up in 6, well, I guess I can live with that.</p> 
                                                        <blockquote style="margin: 10px 0 0; border-left: 1px solid #cccccc; color: #707070; margin-left: 19px; padding: 10px 20px">
                                                            <p style="margin: 10px 0 0; margin-top: 0">Should we keep andByIndexOrder/andByScore<br> +1 to keep them. I also thought they might be useful.</p>
                                                        </blockquote> <p style="margin: 10px 0 0">Will do. I will also add a way to chain an <tt>andByField</tt> after a <tt>byScore</tt>, just in case.</p> 
                                                        <blockquote style="margin: 10px 0 0; border-left: 1px solid #cccccc; color: #707070; margin-left: 19px; padding: 10px 20px">
                                                            <p style="margin: 10px 0 0; margin-top: 0">Should we keep in(Unit)<br> Maybe we could simply provide a fixed value for Elasticsearch (probably meter) and document that?<br> In the long term, we will probably need to be able to define backend specific options but it might not be a priority for now.</p>
                                                        </blockquote> <p style="margin: 10px 0 0">Agreed, a fixed value seems the way to go. I'll check out what the unit for our FullTextQuery.SPATIAL_DISTANCE is, but it seems to be kilometers (<tt>org.hibernate.search.query.engine.impl.DocumentExtractorImpl.extract(int)</tt> =&gt; <tt>org.hibernate.search.query.engine.impl.QueryHits.spatialDistance(int)</tt> =&gt; <tt>org.hibernate.search.spatial.impl.DistanceCollector.HitEntry.getDistance(Point)</tt> =&gt; <tt>org.hibernate.search.spatial.impl.Point.getDistanceTo(double, double)</tt>). A bit odd, but changing it would be an API break, so let's be consistent...</p> 
                                                        <blockquote style="margin: 10px 0 0; border-left: 1px solid #cccccc; color: #707070; margin-left: 19px; padding: 10px 20px">
                                                            <p style="margin: 10px 0 0; margin-top: 0">Is the byDistanceFromSpatialQuery(Query) method making sense<br> It's a useful shortcut. If we can provide a useful error message if the user is not providing a spatial query, I think it's worth it. If it's going to be cryptic, probably not.</p>
                                                        </blockquote> <p style="margin: 10px 0 0">Not sure it's really a shortcut, that was my point. Without it, we'd have this kind of code:</p> 
                                                        <div class="code panel" style="border-width: 1px;; border: 1px solid #cccccc; background: #f5f5f5; font-size: 12px; line-height: 1.333; font-family: monospace; border: 1px solid #cccccc; -moz-border-radius: 3px; border-radius: 3px; margin: 9px 0">
                                                            <div class="codeContent panelContent" style="padding: 9px 12px"> 
                                                                <pre class="code-java" style="margin: 10px 0 0; margin-top: 0; max-height: 30em; overflow: auto; white-space: pre-wrap; word-wrap: normal">
Query luceneQuery = builder.spatial()
                .onField( <span class="code-quote" style="color: #009100">"location"</span> )
                .within( 100, Unit.KM )
                        .ofLatitude( centerLatitude )
                        .andLongitude( centerLongitude )
        .createQuery();
FullTextQuery hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
Sort sort = builder.sort()
        .byField( <span class="code-quote" style="color: #009100">"location"</span> )
                        .fromLatitude( centerLatitude )
                        .andLongitude( centerLongitude )
        .createSort();
hibQuery.setSort( sort );
</pre> 
                                                            </div>
                                                        </div> <p style="margin: 10px 0 0">And with it, that kind of code:</p> 
                                                        <div class="code panel" style="border-width: 1px;; border: 1px solid #cccccc; background: #f5f5f5; font-size: 12px; line-height: 1.333; font-family: monospace; border: 1px solid #cccccc; -moz-border-radius: 3px; border-radius: 3px; margin: 9px 0">
                                                            <div class="codeContent panelContent" style="padding: 9px 12px"> 
                                                                <pre class="code-java" style="margin: 10px 0 0; margin-top: 0; max-height: 30em; overflow: auto; white-space: pre-wrap; word-wrap: normal">
Query luceneQuery = builder.spatial()
                .onField( <span class="code-quote" style="color: #009100">"location"</span> )
                .within( 100, Unit.KM )
                        .ofLatitude( centerLatitude )
                        .andLongitude( centerLongitude )
        .createQuery();
FullTextQuery hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
Sort sort = builder.sort()
        .byField( <span class="code-quote" style="color: #009100">"location"</span> )
                        .byDistanceFromSpatialQuery( luceneQuery )
        .createSort();
hibQuery.setSort( sort );
</pre> 
                                                            </div>
                                                        </div> <p style="margin: 10px 0 0">So we gained one line of code. Out of a dozen. And we lost in clarity, though that's a matter of opinion.<br> Anyway, I'll see if we can at least implement this cleanly.</p> 
                                                        <blockquote style="margin: 10px 0 0; border-left: 1px solid #cccccc; color: #707070; margin-left: 19px; padding: 10px 20px">
                                                            <p style="margin: 10px 0 0; margin-top: 0">Do we want to support sorting on unmapped fields<br> I think it can be considered an acceptable limitation to always sort on common fields. I wouldn't enforce it though so that it continues to work as before for Lucene.<br> It would be something to keep in mind for Search 6.</p>
                                                        </blockquote> <p style="margin: 10px 0 0">Ok to support only common fields. But as to "work as before", the DSL didn't exist "before", so it will only mean that users can provide their own <tt>SortField</tt> through the <tt>byNative</tt> methods.</p> <p style="margin: 10px 0 0">Thanks!</p> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <tr> 
                                    <td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff"> 
                                        <table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> 
                                            <tbody>
                                                <tr> 
                                                    <td id="actions-pattern-container" valign="middle" style="padding: 0; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0"> 
                                                        <table align="left" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                                            <tbody>
                                                                <tr> 
                                                                    <td class="actions-pattern-action-icon-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HSEARCH-1872#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-0dba029d-5723-41c5-ae19-864ddf330976" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle"> </a> </td> 
                                                                    <td class="actions-pattern-action-text-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://hibernate.atlassian.net/browse/HSEARCH-1872#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a> </td> 
                                                                </tr> 
                                                            </tbody>
                                                        </table> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                                <!-- there needs to be content in the cell for it to render in some clients --> 
                                <tr> 
                                    <td class="email-content-rounded-bottom mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #ffffff; border-top: 0; border-left: 1px solid #cccccc; border-bottom: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly" height="5" bgcolor="#ffffff">&nbsp;</td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
                <tr> 
                    <td id="footer-pattern" style="padding: 0; border-collapse: collapse; padding: 12px 20px"> 
                        <table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                            <tbody>
                                <tr> 
                                    <td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0; border-collapse: collapse; color: #999999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px"> This message was sent by Atlassian JIRA <span id="footer-build-information">(v1000.245.0#100009-<span title="7349d1fc3a9a977533e445e375df6c80ccb95983" data-commit-id="7349d1fc3a9a977533e445e375df6c80ccb95983}">sha1:7349d1f</span>)</span> </td> 
                                    <td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0; border-collapse: collapse; padding-left: 20px; vertical-align: top"> 
                                        <table style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0"> 
                                            <tbody>
                                                <tr> 
                                                    <td id="footer-pattern-logo-desktop-padding" style="padding: 0; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="cid:jira-generated-image-static-footer-desktop-logo-e1a57eb0-edf1-4bc7-bf78-a0389b5c8c27" alt="Atlassian logo" title="Atlassian logo" width="169" height="36" class="image_fix"> </td> 
                                                </tr> 
                                            </tbody>
                                        </table> </td> 
                                </tr> 
                            </tbody>
                        </table> </td> 
                </tr> 
            </tbody>
        </table>   
    </body>
</html>