Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Nielsen 99 posts 619 karma points
    Mar 20, 2018 @ 13:03
    Michael Nielsen
    0

    Lucene Spatial Search

    I'm trying to setup spatial search, to get the nearest locations from another location, but I am having trouble getting out results.

    The index looks fine and has data http://prntscr.com/itrup4

    The search itself looks like this

            var clientLatitude = 56.3354034;
            var clientlongitude = 8.651975;
            double KmsToMiles = 0.621371192;
            double _radius = 500 * KmsToMiles;
    
            LuceneIndexer indexer = (LuceneIndexer)ExamineManager.Instance.IndexProviderCollection["ClickAndCollectIndexer"];
            IndexSearcher searcher = new IndexSearcher(indexer.GetLuceneDirectory(), false);
    
            BooleanQuery criteria = new BooleanQuery();
            criteria.Add(new TermQuery(new Term("nodeTypeAlias", "clickandcollecttype")), BooleanClause.Occur.MUST);
    
            Lucene.Net.Search.Filter distanceFilter = new DistanceQueryBuilder((double)clientLatitude, (double)clientlongitude, Convert.ToDouble(_radius), "codedlat", "codedlong", CartesianTierPlotter.DefaltFieldPrefix, true).Filter;
    
            var results = searcher.Search(criteria, distanceFilter, searcher.MaxDoc());
    

    Cannot seem to figure out where my problem is.

  • Michael Nielsen 99 posts 619 karma points
    Mar 20, 2018 @ 21:42
    Michael Nielsen
    100

    Found the answer to the problem.

    Not having the tiers in the index config, but rather creating them as suggested by Ismail here

    https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/89160-auto-index-examine-fields-from-custom-data-source-using-lucene-spatial-search#comment-281868

    makes it work.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies