in Education by
I'm using Elasticsearch 6.6 and have an index (1 shard, 1 replica) with the geonames (https://www.geonames.org/) dataset indexed (indexsize =1.3 gb, 11.8 mio geopoints). I was playing around a bit with the geo distance sorting query, sorting the whole index for some origin points. So after some testing I saw that sorting ascending is always faster than sorting descending. here is an example query (i also tested with bigger "size"-parameter): POST /geonames/_search?request_cache=false { "size":1, "sort" : [ { "_geo_distance" : { "location" : [8, 49], "order" : "asc", "unit" : "m", "mode" : "min", "distance_type" : "arc", "ignore_unmapped": true } } ] } Here is the answer for ascending sorting (with explain and profile True): { "took" : 1374, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 11858060, "max_score" : null, "hits" : [ { "_shard" : "[geonames][0]", "_node" : "qXTymyB9QLmxhPtGEtA_mA", "_index" : "geonames", "_type" : "doc", "_id" : "L781LmkBrQo0YN4qP48D", "_score" : null, "_source" : { "id" : "3034701", "name" : "Forêt de Wissembourg", "location" : { "lat" : "49.00924", "lon" : "8.01542" } }, "sort" : [ 1523.4121312414704 ], "_explanation" : { "value" : 1.0, "description" : "*:*", "details" : [ ] } } ] }, "profile" : { "shards" : [ { "id" : "[qXTymyB9QLmxhPtGEtA_mA][geonames][0]", "searches" : [ { "query" : [ { "type" : "MatchAllDocsQuery", "description" : "*:*", "time_in_nanos" : 265223567, "breakdown" : { "score" : 0, "build_scorer_count" : 54, "match_count" : 0, "create_weight" : 10209, "next_doc" : 253091268, "match" : 0, "create_weight_count" : 1, "next_doc_count" : 11858087, "score_count" : 0, "build_scorer" : 263948, "advance" : 0, "advance_count" : 0 } } ], "rewrite_time" : 1097, "collector" : [ { "name" : "CancellableCollector", "reason" : "search_cancelled", "time_in_nanos" : 1044167746, "children" : [ { "name" : "SimpleFieldCollector", "reason" : "search_top_hits", "time_in_nanos" : 508296683 } ] } ] } ], "aggregations" : [ ] } ] } } and here for descending, just switched the parameter from asc to desc (also with profile and explain): { "took" : 2226, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 11858060, "max_score" : null, "hits" : [ { "_shard" : "[geonames][0]", "_node" : "qXTymyB9QLmxhPtGEtA_mA", "_index" : "geonames", "_type" : "doc", "_id" : "Mq80LmkBrQo0YN4q11bA", "_score" : null, "_source" : { "id" : "4036351", "name" : "Bollons Seamount", "location" : { "lat" : "-49.66667", "lon" : "-176.16667" } }, "sort" : [ 1.970427111052182E7 ], "_explanation" : { "value" : 1.0, "description" : "*:*", "details" : [ ] } } ] }, "profile" : { "shards" : [ { "id" : "[qXTymyB9QLmxhPtGEtA_mA][geonames][0]", "searches" : [ { "query" : [ { "type" : "MatchAllDocsQuery", "description" : "*:*", "time_in_nanos" : 268521404, "breakdown" : { "score" : 0, "build_scorer_count" : 54, "match_count" : 0, "create_weight" : 9333, "next_doc" : 256458664, "match" : 0, "create_weight_count" : 1, "next_doc_count" : 11858087, "score_count" : 0, "build_scorer" : 195265, "advance" : 0, "advance_count" : 0 } } ], "rewrite_time" : 1142, "collector" : [ { "name" : "CancellableCollector", "reason" : "search_cancelled", "time_in_nanos" : 1898324618, "children" : [ { "name" : "SimpleFieldCollector", "reason" : "search_top_hits", "time_in_nanos" : 1368306442 } ] } ] } ], "aggregations" : [ ] } ] } } So my question is, why is it like this ? As I understood Es calculates the distance from the origin point to every other point and then sorts them. So why is the descending sorting so much slower ? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Asking the same question on the Elasticsearch board and getting an answer. So apparantly Elasticsearch uses differnt searching strategies/algorithms for ascending end descending distance sorting. For the descending sorting it calculates the distance from the origin to every point end then sorts. For the ascending sorting it uses boundingboxes to filter points near the origin and only calculate the distances for points inside the boundingboxes.

Related questions

0 votes
    Why is the training of basis function is faster than MLFFNN? (a) because they are developed specifically for pattern ... d) none of the mentioned Please answer the above question....
asked Aug 27, 2022 in Education by JackTerrance
0 votes
    Why does a sorted array get processed faster than an unsorted array, even though the size of the arrays are ... processed faster. Why? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Here is a piece of C++ code that shows some very peculiar behavior. For some strange reason, sorting the data ... = static_cast(clock()-start) / CLOCKS_PER_SEC; std::cout...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    It was faster more reliable smaller and much cheaper to build than a vacuum tube. Select the correct answer from above options...
asked Dec 16, 2021 in Education by JackTerrance
0 votes
0 votes
    AES is at least 6-times faster than 3-DES. (a) True (b) False The question was asked in homework. ... ?,Need-for-Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    __________ is increasingly being used in server systems to improve performance by caching frequently used data, ... in portion Storage and File Structures of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    __________ configuration is faster than ___________ configuration. Manual, Hybrid Automated, Manual Manual, Automated Automated, Hybrid...
asked Sep 15, 2021 in Technology by JackTerrance
0 votes
    HOW DO I SORT THIS BY BIRTHYEAR IN ASCENDING ORDER? I'm distance learning student and have no help. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    Explain what is the command “d3.ascending (a, b)” is used?...
asked Nov 14, 2020 in Technology by JackTerrance
0 votes
    struts 1.x I have always defined a struts form action mapping with scope="request" unless forced into ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    def main(): for i in xrange(10**8): pass main() This piece of code in Python runs in (Note: The timing is ... sys 0m0.012s Why is this? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    Why applications compiled with AOT (Ahead of compilation) launch faster?...
asked Jun 28, 2021 in Technology by JackTerrance
...