Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SolrNet空间搜索-基于geodist()的排序_C#_Solr_Solrnet - Fatal编程技术网

C# SolrNet空间搜索-基于geodist()的排序

C# SolrNet空间搜索-基于geodist()的排序,c#,solr,solrnet,C#,Solr,Solrnet,我正在将Solr(3.6.0)与SolrNet(0.4)一起使用,我正在寻找SolrNet中空间搜索方面的帮助—具体来说,就是按距离对结果进行排序 我的问题是: var postcode = new SolrQueryByField("Postcode", fields[13]); var distance = new SolrQueryByDistance("LatLong", latitude, longitude, 1); QueryOptions options = new QueryO

我正在将Solr(3.6.0)与SolrNet(0.4)一起使用,我正在寻找SolrNet中空间搜索方面的帮助—具体来说,就是按距离对结果进行排序

我的问题是:

var postcode = new SolrQueryByField("Postcode", fields[13]);
var distance = new SolrQueryByDistance("LatLong", latitude, longitude, 1);
QueryOptions options = new QueryOptions();
options.Rows = 25;
options.AddFilterQueries(distance);
我尝试过一些显而易见的事情:

options.OrderBy = new List<SortOrder> { new SortOrder("geodist()", Order.ASC)};
我还尝试将lat、long和distance参数传递给geodist()函数,但没有成功

我可以手工构造这个查询,只是不能通过SolrNet!问题似乎与查询字符串的排序和括号方式有关

本工程(手工施工):

{d=1&sort=geodist()+asc&sfield=LatLong&version=2.2&rows=25&q=Postcode:“LN1+2EB”&pt=52.1,-1.11&fq={!geofilt}

失败(由SolrNet构建):

{d=1&sort=geodist()+asc&q=(邮政编码:“LN1+2EB”)&sField=LatLong&pt=53.289186,-0.705095&fq={!geofilt}&rows=25&version=2.2}


我想我在做些傻事;一定有办法让这个功能发挥作用!任何指针都将不胜感激。

这将按距离排列结果。取消对行的注释,以按与点的距离过滤

solr.Query(SolrQuery.All,
                              new QueryOptions
                                  {
                                      FilterQueries = filterQueries.ToArray(), // add filter items
                                      OrderBy = new[] { new SolrNet.SortOrder("geodist()", Order.ASC) },
                                      ExtraParams = new Dictionary<string, string>
                                          {
                                              // uncomment for filtering by distance
                                              //{"fq", "{!geofilt}"},
                                              //{"d", distance.ToString(CultureInfo.InvariantCulture)} replace distance with your radius filter
                                              {"sfield", "lat_long"}, // replace lat_long with your field in solr that stores the lat long values
                                              {"pt", "-33.858727,151.213199"}, // this is the point of reference
                                                                                        }
                                  });
solr.Query(SolrQuery.All,
新查询选项
{
FilterQueries=FilterQueries.ToArray(),//添加筛选器项
OrderBy=new[]{new SolrNet.SortOrder(“geodist()”,Order.ASC)},
ExtraParams=新字典
{
//取消按距离过滤的注释
//{“fq”,{!geofilt},
//{“d”,distance.ToString(CultureInfo.InvariantCulture)}用半径过滤器替换距离
{“sfield”,“lat_long”},//将lat_long替换为solr中存储lat long值的字段
{“pt”,“-33.858727151.213199”},//这是参考点
}
});
options.ExtraParams = new Dictionary<string, string>
{
    {"d", "1"},                        
    {"sField", "LatLong"},
    {"pt", latitudeString + "," + longitudeString},
    {"fq", "{!geofilt}"},
    {"sort", "geodist() asc"}
};
SEVERE: org.apache.solr.common.SolrException: can not sort on unindexed field: geodist()
solr.Query(SolrQuery.All,
                              new QueryOptions
                                  {
                                      FilterQueries = filterQueries.ToArray(), // add filter items
                                      OrderBy = new[] { new SolrNet.SortOrder("geodist()", Order.ASC) },
                                      ExtraParams = new Dictionary<string, string>
                                          {
                                              // uncomment for filtering by distance
                                              //{"fq", "{!geofilt}"},
                                              //{"d", distance.ToString(CultureInfo.InvariantCulture)} replace distance with your radius filter
                                              {"sfield", "lat_long"}, // replace lat_long with your field in solr that stores the lat long values
                                              {"pt", "-33.858727,151.213199"}, // this is the point of reference
                                                                                        }
                                  });