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

    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

    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

    Found the answer to the problem.

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

    makes it work.

Please Sign in or register to post replies

Write your reply to: