Want bbox query and have the distance returned for spatial search solrnet

49 views
Skip to first unread message

Kasturi Chavan

unread,
Oct 19, 2015, 3:20:06 PM10/19/15
to SolrNet
var query = SolrQueryByDistance(fieldname, loc, (int)Math.Ceiling(distance), CalculationAccuracy.BoundingBox);

string point = latitude + "," + longitude;
QueryOptions queryOptions = new QueryOptions
{
OrderBy = new[] {new SortOrder("geodist()", Order.ASC) , new SortOrder(QuerystringUtil.KEY_IS_PREFERRED, Order.DESC)},
                                Fields = new[] {"*", "distance: geodist()"},
ExtraParams = new Dictionary<string, string> {
{"sfield","agency_loc"},
{"pt", point}
}
};

This does not return the results for me.I have field named distance in the results object. I need it to store the geodist(). How can i do that using solrnet

Kasturi Chavan

unread,
Oct 19, 2015, 3:21:36 PM10/19/15
to SolrNet
This does not return the results for me.I have field named distance in the results object. I need it to store the geodist(). How can i do that using solrnet?

If I use  
QueryOptions queryOptions = new QueryOptions
{
OrderBy = new[] {new SortOrder("geodist()", Order.ASC) , new SortOrder(QuerystringUtil.KEY_IS_PREFERRED, Order.DESC)},
ExtraParams = new Dictionary<string, string> {
{"sfield","agency_loc"},
{"pt", point}
}
};

I get the results correct, but still no distance is returned.

Mauricio Scheffer

unread,
Oct 19, 2015, 6:06:33 PM10/19/15
to sol...@googlegroups.com
1. Not sure whether a space is allowed between the pseudo-field name and the geodist() expression.
2. Not sure whether a pseudo-field name without underscore is allowed. All the examples I've seen and IIRC the pseudo-fields I've used start with an underscore.

So in a nutshell, try: Fields = new[] {"*", "_dist_:geodist()"}

and of course map "_dist_" to a property in the results class.

Cheers






--
Mauricio

--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.
To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages